1. Balanced group/recursive match
(? 'Group') Name the content corresponding to the group and press the stack count;
(? '-Group') returns the corresponding content named 'group' to the stack count.
(?!) Assertion with Zero Width and negative direction, attempts to match always fail because there is no suffix expression
Regular Expression example:
, {0, 1} "5": \ [^ \ [\] * (? 'Open' \ [) [^ \ [\] *) + ((? '-Open' \]) [^ \ [\] *) + )*(? (Open )(?!)) \], {0, 1}
Test data:
{"0": ["0", "0-1", "0-2"], "1": ["1", "1-1 ", "1-2"], "2": ["2", "2-1", "2-2"], "3": ["3 ", "3-1", "3-2"], "4": ["4", "4-1", "4-2"], "5 ": ["5", "5-1", "5-2"]}
Comparison result: "1": ["1", "1-1", "1-2"],
Comments: This is a good one. To retrieve the latest one ].
2. Zero-width assertion
(? = Exp) match the position before exp
(? <= Exp) match the position behind exp
(?! Exp) the position behind the matching is not the exp position.
(? <! Exp) match the position not above exp
Regular Expression example:
(? <= <(\ W +)> ).*(? = <\/\ 1>)
Test data:
<Li> <a href = "# updatelog"> Update records </a> </LI>
Comparison result: <a href = "# updatelog"> Update record </a>
Comments: This is a good one. You can get the start and end, but it cannot be in the <A> .... </a> <A>... </a> the hmtl does not allow <A> to appear again <A>. If it is a DIV, it must be written as follows.
<[^ <>] * (? 'Open' <) [^ <>] *) + ((? '-Open'>) [^ <>] *) + )*(? (Open) (?!)>
<Div class = "NOTE"> AAA <div> other available test tools: </div> BBBB </div> <a href = "www. *****. com "> gogogo </a> </div>