-1

I have this string

§serverUrl§/image/?url=§externalMedia.data.image§

and I want to match only the string inside the § character. (serverUrl and externalMedia.data.image). I'm using this pattern :

/§.+§/g

but it catches also the characheters between the two groups.

Any help would be appreciate. Thanks

Nemus
  • 1,322
  • 2
  • 23
  • 47
  • 2
    `/§(.+?)§/g` or `/§(.*?)§/g` or `/§([^§]+)§/g` or `/§([^§]*)§/g` and use the `RegExp.exec()` in a loop to get all the substrings inside. See [*How do you access the matched groups in a JavaScript regular expression?*](http://stackoverflow.com/questions/432493/how-do-you-access-the-matched-groups-in-a-javascript-regular-expression). – Wiktor Stribiżew Mar 15 '16 at 13:57
  • How to exclude the '§' from the match? – Nemus Mar 15 '16 at 14:02
  • See [*How do you access the matched groups in a JavaScript regular expression?*](http://stackoverflow.com/questions/432493/how-do-you-access-the-matched-groups-in-a-javascript-regular-expression), use `match[1]` – Wiktor Stribiżew Mar 15 '16 at 14:11

1 Answers1

0

You will have to make it lazy using ? like this §.+?§

Regex101 Demo