smiron
smiron

Reputation: 408

Regular expression match issue

I have a simple regular expression: .} and some simple text: {}}

Why do I get a single match:

I was expecting to get two:

Please see here for the code snippit.

Upvotes: 0

Views: 38

Answers (1)

Brian H
Brian H

Reputation: 1041

Regex matches are non-overlapping. Maybe some like this is closer to what you want:

/(?=})}/g

I think you actually want look behind not look ahead but this isn't supported on regexr.com because it's not supported in java script

/(?<=})}/g

Upvotes: 1

Related Questions