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
\{{(.*?)\}}
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.
Try the following:
(?<=\{{)(.*?)(?=\}})
it works for
{{text is here}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.