user2672288
user2672288

Reputation:

js regex between strings with repeated characters

I want to match on the contents of some code between the strings var and );

I'm currently using:

var([^)]+)\);

And this matches, except for when another closing bracket appears elsewhere in the text. So,

var (this does match);
var (this) doesn't match but should);

Regex example here

Upvotes: 0

Views: 20

Answers (1)

quirimmo
quirimmo

Reputation: 9988

You could use simply this one if I understood fine what you want to match:

/var(.*);/

Upvotes: 1

Related Questions