简体   繁体   中英

Regex with $ anchor and look ahead

/ab(?=.{1})$/g doesn't match "abdabd" or anything else

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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