简体   繁体   English

带有$锚的正则表达式,展望未来

[英]Regex with $ anchor and look ahead

/ab(?=.{1})$/g doesn't match "abdabd" or anything else /ab(?=.{1})$/g与“ abdabd”或其他不匹配

It's the anchor $ that is troubling me. 是锚$困扰着我。 What can this regex match ? 这个正则表达式可以匹配什么?

What can this regex match ? 这个正则表达式可以匹配什么?

This regex won't match anything and is guaranteed to fail because: 此正则表达式将不匹配任何内容,并保证会失败,因为:

ab       - will literally match ab
(?=.{1}) - will use lookup to make sure there is at least 1 character after ab
$        - will assert end of input after ab

both conditions can never be met hence your regex will always fail. 这两个条件都无法满足,因此您的正则表达式将始终失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM