1. Balanced group/recursive matching
(?'group') Press the stack to count the content corresponding to the group;
(?'-group') count the corresponding content named group
(?!) Zero-width negative direction assertion, attempts to match always fail because there is no suffix expression
Regular 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"],
Comment: This is very well written. Can achieve the effect of taking out the most recent one]
2. Zero width assertion
(?=exp) Match the position in front of exp
(?<=exp) Match the position after exp
(?!exp) Match the position that is not exp after it
(?<!exp) Match the position that is not exp before
Regular example:
(?<=<(\w+)>).*(?=<\/\1>)
Test data:
<li><a href="#updatelog">Update the record</a></li>
Comparison results: <a href="#updatelog">Update record</a>
Comment: This is very well written. You can get the start and end, but you cannot see the <a>...</a> again in <a>...</a>. Fortunately, you cannot see the <a> again in <a> in <a>. If it is like DIV, you have to write it in the following way.
<[^<>]*(((?'Open'<)[^<>]*)+((?'-Open'>)[^<>]*)+)*(?(Open)(?!))>
<div class="note">aaa<div>Other available testing tools:</div>bbbb</div><div><a href="www.******.com">gogogo</a></div>
(?'group') Press the stack to count the content corresponding to the group;
(?'-group') count the corresponding content named group
(?!) Zero-width negative direction assertion, attempts to match always fail because there is no suffix expression
Regular 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"],
Comment: This is very well written. Can achieve the effect of taking out the most recent one]
2. Zero width assertion
(?=exp) Match the position in front of exp
(?<=exp) Match the position after exp
(?!exp) Match the position that is not exp after it
(?<!exp) Match the position that is not exp before
Regular example:
(?<=<(\w+)>).*(?=<\/\1>)
Test data:
<li><a href="#updatelog">Update the record</a></li>
Comparison results: <a href="#updatelog">Update record</a>
Comment: This is very well written. You can get the start and end, but you cannot see the <a>...</a> again in <a>...</a>. Fortunately, you cannot see the <a> again in <a> in <a>. If it is like DIV, you have to write it in the following way.
<[^<>]*(((?'Open'<)[^<>]*)+((?'-Open'>)[^<>]*)+)*(?(Open)(?!))>
<div class="note">aaa<div>Other available testing tools:</div>bbbb</div><div><a href="www.******.com">gogogo</a></div>