Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-01 07:41:13 09月22日 Update

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 (?

Tags: Characters regular letters numbers grouping text expressions tests consumption meaning subscript content uppercase uppercase lowercase articles language processing foresight variables Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info MariaDB Docker macOS