Mathematica
Mathematica

Reputation: 41

Get string between two substrings

I want to get a string between two substrings.

For example:

Code:

'{{something}} Space {}} Space2 {{}}'.match(/{(.*?)}/g)

I want it to be:

['{something}','}','{}']

but it returns:

['{{something}','{}','{{}']

Upvotes: 0

Views: 231

Answers (1)

Scott Sauyet
Scott Sauyet

Reputation: 50787

This looks like it would get the answer you want in this case, but the general case is not very clear to me:

'{{something}} Space {}}'.match(/{([^{]*?)}/g)

Upvotes: 2

Related Questions