Java – regular expression with = and a

I try to use regular expressions to find all substrings that start with an equal sign (=) and start with a semicolon (;) End with any number of characters It should be like this = *;

For some reason, equality is not registered Is there any escape character that causes the regular expression to tell me the equal sign?

If there is any relationship on this issue, I am working in Java

Solution

This may be what you are looking for You need to specify the character set or wildcard to which you want to apply the asterisk

"=([^;]*);"

You can also use reluctant quantifiers:

"=(.*?);"

Using parentheses, you now have groups I believe the first group is the whole game, and group [1] is the group found in parentheses

The code may be as follows:

Regex r = new Regex("=([^;]*);");
Match m = r.Match(yourData);
while (m.Success) {
    string match = m.Groups[1];
    // match should be the text between the '=' and the ';'.
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>