The regular expression matches that we've learned are all "width" and will match with \w+。
The following text: 。
Regular Expression
If you do not want to match the symbol, match only one position, use the "0 wide assertion" (Match width is zero, satisfy certain condition/assertion), 0 wide assertion use (? = expression) syntax, \w+(?=。)
For example, where (?=。)
represents 。
the previous position (antecedent assertion)
Regular expression.
If you need to match a later location, such as:
。 regular . expression
Then use (?<=。)
(?<=。)\w+
The post assertion to get the above matching result
Use (?<=<b>).*(?=</b>)
content from a matching tag
<b> Bold </b>
Negative 0 Wide Assertion
Negative to 0 wide assertion (?! Expression) is also a position that matches a 0 width, but the "assertion" of the position takes the inverse of the expression (?!表达式)
, 表达式
For example to indicate the 表达式
previous position, if not, Match this position, if 表达式
It is, it does not match:
expression expression,expression, expression.
The above is .+n(?!。)
the matching result used. Note the difference from the match .+n[^。]
Expressionexpression,expression, expression.
Similarly, negative 0-wide assertions also have "antecedent" and "post-hair" two, negative 0-wide after the assertion is (? <! expression)
Use (?<![</])para(?!>)
match text below
<para>para represents a paragraph </para>
(?<![</])
Indicates that para
the <
left cannot be or /
(?!>)
is not the para
right>
The zero width assertion of JS regular