0

I'm using PhpStorm and I'd like to find shortest string between {{ and }} by using Regex. An example is like this:

{{$ux['friend']['profile']['firstName']}} {{$ux['friend']['profile']['familyName']}}

I tried this:

\$(.*)(\['.*'\])+

which finds like this

$ux['friend']['profile']['firstName']}} {{$ux['friend']['profile']['familyName']

but I want to make it non-greedy -- only find the string between each match of {{ and }} like

$ux['friend']['profile']['firstName']
LazyOne
  • 158,824
  • 45
  • 388
  • 391
Omid
  • 41
  • 5
  • As usual, just add `?` after `.*`. See [`\$.*?(?:\['.*?'\])+`](https://regex101.com/r/mS5xS4/1). Or a negated character clas variation: [`\$\w+(?:\['[^\]\[]*'\])+`](https://regex101.com/r/mS5xS4/2) – Wiktor Stribiżew Jul 25 '16 at 08:51
  • yep, it works, thanks, – Omid Jul 25 '16 at 08:56

0 Answers0