Skip to content Skip to sidebar Skip to footer

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 ?

Solution 1:

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 assertend of input after ab

both conditions can never be met hence your regex will always fail.

Post a Comment for "Regex With $ Anchor And Look Ahead"