Regex to get string between curly braces

Try

/{(.*?)}/

That means, match any character between { and }, but don’t be greedy – match the shortest string which ends with } (the ? stops * being greedy). The parentheses let you extract the matched portion.

Another way would be

/{([^}]*)}/

This matches any character except a } char (another way of not being greedy)

Leave a Comment