Example Analysis of Abba reverse prospective regular matching in js
This article mainly shows you the "example analysis of Abba reverse forward regular matching in js", which is easy to understand and well organized. I hope it can help you solve your doubts. Let me lead you to study and learn this article "example analysis of Abba reverse forward regular matching in js".
Core code:
Var S1 = 'acritan';var S2 =' bassarisk';var S3 = 'commotive';// find the words var r = / ^ (?!. *? (.) (.)\ 2\ 1) / r.test (S1); / truealert (r.test (S2)); / / falsealert (r.test (S2)); / / false
Zero width assertion (?! exp)
Anti-antecedent assertion
What is an anti-antecedent assertion? using (?! exp) matching is not followed by exp.
Php instance:
I mainly want to tell you about the role of this rule through an example.
$str= "abcgwcab"; $parent='/bc (?! ww) gw/';$str=preg_match ($parent,$str,$match); var_dump ($str); var_dump ($match); / * * output: int 1array (size=1) 0 = > string 'bcgw' (length=4) * /
Parsing: first determine whether the string contains bc, then determine that it is not followed by ww, and finally match gw. You can see that before and after the reverse assertion, you can add other matching conditions.
. *?
This. * is to match any length of non-empty characters. That is, the non-greedy pattern is to match the fewest characters, such as one character.
The above is all the content of the article "sample Analysis of Abba reverse forward-looking regular matching in js". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!