0

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

0

1 Answer 1

1

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

/var(.*);/
Sign up to request clarification or add additional context in comments.

2 Comments

This will need g flag
yes, that works! its always the simple answers that are best.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.