0

With

test(test) = 

I want to match

test( 

With

test = test

I want to match

test = 

I tried this regex

/.+[\(=]/

but it will give the whole string for

test(test) =

instead of

test(

user310291
  • 33,174
  • 71
  • 241
  • 439
  • 1
    This is just a greedy vs. lazy matching issue. Add a `?` to your greedy quantifier to make it lazy, like so: `/.+?[\(=]/` – Charlie Armstrong Mar 08 '21 at 02:55
  • @CharlieArmstrong thanks I searched all over google but couldn't find it :) – user310291 Mar 08 '21 at 03:00
  • 2
    Does this answer your question? [What is the difference between .\*? and .\* regular expressions?](https://stackoverflow.com/questions/3075130/what-is-the-difference-between-and-regular-expressions) – Charlie Armstrong Mar 08 '21 at 03:04

0 Answers0