相关疑难解决方法(0)

贪婪与不情愿与占有量词

我发现这个关于正则表达式的优秀教程,虽然我直观地理解"贪婪","不情愿"和"占有欲"量词的作用,但我的理解似乎存在严重漏洞.

具体来说,在以下示例中:

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 0 and ending at index 4.
I found the text "xxxxxxfoo" starting at index 4 and ending at index 13.

Enter your regex: .*+foo // possessive quantifier
Enter …
Run Code Online (Sandbox Code Playgroud)

regex regex-greedy

342
推荐指数
5
解决办法
9万
查看次数

参考 - 这个正则表达式意味着什么?

这是什么?

这是常见问答的集合.这也是社区Wiki,因此每个人都被邀请参与维护.

为什么是这样?

患的是给我泽码型的问题和答案不佳,没有解释.此参考旨在提供质量问答的链接.

范围是什么?

此引用适用于以下语言:,,,,,,.

这可能过于宽泛,但这些语言共享相同的语法.对于特定功能,它背后的语言标签,例如:

  • 什么是正则表达式平衡组?

regex

52
推荐指数
1
解决办法
11万
查看次数

标签 统计

regex ×2

regex-greedy ×1