jack-zheng
3/16/2018 - 1:02 PM

regex, 贪婪, 非贪婪

regex, 贪婪, 非贪婪

贪婪: 尽可能匹配多 非贪婪: 尽可能匹配少

matched: 
<table>asdf</table><p><br /></p><p><br /></p><table><tbody><tr><th>ACTitle2</th><th>TestlinkId</th><th>Comment</th></tr><tr><th>t01</th><th>PLT#-01</th><th /></tr><tr><th>t02</th><th>PLT#-02</th><th /></tr></tbody></table>'

non-greedy: (?<=<(table)>).*?(?=<\/\1>)
result:

asdf and <tbody>...</tbody>

greedy: (?<=<(table)>).*(?=<\/\1>)
result: <table>asdf</ta...<body..../body>