airnet
airnet

Reputation: 2673

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 ?

Upvotes: 0

Views: 434

Answers (1)

anubhava
anubhava

Reputation: 786081

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.

Upvotes: 5

Related Questions