PHP extension text processing -- PCRE regular expression syntax 11 -- asserted an asserted is a test of the character before or after the current matching position, which does not actually consume any characters. Simple asserted codes include \ B, \ B, \ A, \ Z, \ z, ^, and $. More complex assertions are encoded as child groups. It has two types: Forward-looking assertions (test from the current position forward) and backward-looking assertions (test from the current position backward ).
An assertion sub-group is still matched in the normal way. The difference is that it will not cause the current match point to change. The positive assertions in the forward-looking assertions (asserted that this match is true) take "(? = "Start with". negative assertions start "(?!" . For example, \ w + (? =;) Match a word followed by a semicolon, but the matching result does not contain a semicolon, foo (?! Bar) matches all "foo" strings that are not followed by "bar. Pay attention to a similar mode (?! Foo) bar. it cannot be used to find all the bar matches that are not "foo". it will find any bar match, because (?! Foo) this assertion will always be TRUE when bar is in the next three characters. This is what the forward-looking assertions need to achieve.
The frontend assertions in the rear-view assertion use "(? <= "Start with". negative assertions start "(?
Multiple assertions (in any order) can appear at the same time. For example (? <= \ D {3 })(?
In this case, check that the first three are digits, and then the second one is checked (the current match point) the first three characters are not "999 ".
Assertions can be nested with any complexity. For example (? <= (?
When a sub-group is asserted, the sub-group is not captured and cannot be modified with quantifiers, because it is meaningless to perform multiple assertions on the same thing. if all assertions contain one capture sub-group, they will be included for the purpose of capturing the sub-group count in the entire mode. However, substring capture can only be used for positive assertions, because it is meaningless for negative assertions.
The maximum number of sub-groups that can be attached to an assertion is 200.