Reputation: 484
I need to get an array of all strings that are contained in curly brackets using JavaScript.
{{text is here}}
note that the text could contain all special characters and could be multi line i have tried this so far regex test
\{{(.*?)\}}
Upvotes: 0
Views: 66
Reputation: 48711
In your demo you enabled m
flag which is a wrong flag here. You need s
flag or even without flags:
{{([^]*?)}}
Note: You don't need to escape braces here.
Upvotes: 2
Reputation: 4067
Try the following:
(?<=\{{)(.*?)(?=\}})
it works for
{{text is here}}
https://regex101.com/r/gYXSbO/7/
Upvotes: 1