Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The regularity of Java?: =?! What does it mean?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail the meaning of "the regularity of Java?! what is the meaning of this article? hope that this article" the regularity of Java?: =?! "can help you solve your doubts.

Java regular?: =?! The understanding of

1: explain whether to get a match and save the matching value

() means to capture packets, get matches, and () save the matching values in each group.

(?:) indicates that the non-capture packet is matched, and the value of the match is not saved, which can improve the execution speed of the program.

(?)

Examples are as follows:

/ / whether to get the matching test text abxoxcd.. (xox).. Match abxoxcd. (?: xox).. Match abxoxcd. (? = xox).. Matching abxo acquires a match. Generally, after a character is matched, the character is consumed and output. No match is obtained, no characters are consumed. / / whether to save the matching value test text AAABBCaaA E666FF (A)\\ 1* match AAA, A (\\ w)\\ 1 + match AAA, BB, aa, 666, FF (?: a) (B)\\ 1* match ABB because the non-capture packet does not save the matching value, so (?: a) (B)\ 1* matches the first\\ 1 of the ABB indicates (B) the value captured by this capture group. "Note: backreferences represent captured values instead of using regular expressions again." A new knowledge point is used here, backreferences.

1. "\ number" in the regular expression indicates a backreference and refers to a capture group, which needs to be used together with parentheses "()".

2. The subscript of the regular capture group starts at 0, the group with subscript 0 is the entire expression, and the subscript 1 indicates the value contained in the first left parenthesis from left to right, and so on.

3. When the capture group matches successfully, the contents of the subexpression match will be saved to a numbered group in memory, which can simply be thought of as an assignment to a local variable. At this time, the value of this local variable can be referenced by reverse reference.

4. Reverse references must be used with capture groups. If no capture groups are used, but the syntax of reverse references is used, different languages have different processing methods. Some languages will throw exceptions, and some languages will treat them as common escapes.

2: explain forward pre-check and reverse pre-check / / Prospect: exp1 (? = exp2) find the exp1// in front of exp2: (? Examples are as follows:

/ / forward and reverse pre-check test text abxoxcd. (? = xox) matches ab. (? = oxo) does not match (? = xox).. Match xo (?

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report