Assertion of the regular expression with Zero Width and assertion of the Regular Expression
When learning the Regular Expression of. NET, I am confused about the assertion with Zero Width. I took some time to study and take a note.
Assertion Overview |
(? <= Pattern )(? <! Pattern)STRING(? = Pattern )(?! Pattern): the relative position of various assertions. ? <LookbehindSTRING<Lookahead: NegativeSTRINGForward =: Positive, Positive, indicating matching ! : Negative, no, indicating no match |
(? = Pattern) |
Zero-width positive lookahead. If it is not a get match, search for it from the right of the string. It must match pattern. For example (? = 95 | 98 | NT | 2000) "can match" Windows "in" Windows2000 ", but cannot match" Windows "in" Windows3.1 ". Pre-check does not consume characters, that is, after a match occurs, it will continue fromSTRINGThen start the next matching search, instead of starting from after pattern. Same below |
(?! Pattern) |
Zero-width negative lookahead (0-width negation). If it is not a get match, it is searched from the right side of the string and must not match pattern. For example, "Windows (?! 95 | 98 | NT | 2000) "can match" Windows "in" Windows3.1 ", but cannot match" Windows "in" Windows2000 ". |
(? <= Pattern) |
Zero-width positive lookbehind. If the string is not retrieved, the string must match pattern on the left .. For example, <= 95 | 98 | NT | 2000) Windows can match Windows in 2000Windows, but cannot match Windows in 3.1Windows ". |
(? <! Pattern) |
Zero-width negative lookbehind (Zero-width negative), non-get match, search from the left side of the string, must not match pattern. For example, "(? <! 95 | 98 | NT | 2000) Windows can match "Windows" in "3.1Windows", but cannot match "Windows" in "2000Windows ". |