An example of how Java uses regular expressions to get sub text

This article illustrates how Java uses regular expressions to get sub text. Share with you for your reference, as follows:

Originally, group refers to (), group (0) refers to the whole string, group (1) refers to the things in the first bracket, and group (2) refers to the things in the second bracket.

Recently, I learned regular expressions and found that some terms in Java are different from those described elsewhere. On this issue, I stuck for a long time, Keng dad, wrote a blog for the convenience of other new friends. For example, the concept of "group" in Java regular expression is actually the same as the "sub expression" described in the book "regular expression must know", but the expression is different. This also leads to a lack of understanding of group (int group), start (int group) and end (int group) when using Java API.

JavaScript regular expression online test tool: http://tools.jb51.net/regex/javascript

Regular expression online generation tool: http://tools.jb51.net/regex/create_reg

For more information about Java algorithms, readers who are interested can see the topics on this site: complete collection of Java regular expression skills, tutorial on Java data structure and algorithms, summary of Java DOM node operation skills, summary of java file and directory operation skills, and summary of Java cache operation skills

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
分享
二维码
< <上一篇
下一篇>>