7
贪婪vs.勉强vs.占有量词
我找到了这本关于正则表达式的出色教程,尽管我直观地理解“贪婪”,“勉强”和“可能”量词的作用,但我的理解似乎还存在严重的漏洞。 具体来说,在以下示例中: Enter your regex: .*foo // greedy quantifier Enter input string to search: xfooxxxxxxfoo I found the text "xfooxxxxxxfoo" starting at index 0 and ending at index 13. Enter your regex: .*?foo // reluctant quantifier Enter input string to search: xfooxxxxxxfoo I found the text "xfoo" starting at index …
357
regex
regex-greedy