Qiku ← Back to library

AI / Coding and Debugging

Greedy Match Ate the Whole Line

Greedy Match Ate the Whole Line — Chinese original prompt

这条正则 [正则] 在本该只匹配一处的地方匹配了整段。请解释贪婪量词在这里的具体行为,给出非贪婪、排除字符类、加锚点三种改法,比较它们在最深嵌套那一条输入上的结果,最后说明在 [语言] 里哪种最稳。
Site original

Chinese original

How to use

能用排除字符类就别依赖非贪婪,后者容易跨段。

More in this topic