Search code examples
regexregex-groupregex-negation

extract variable between {{}} using Regex


I have a string in this format {{varx.vary}}, {{varz.varu}} and {{var1.var2.var3} i have written a regex expression ([^{}]+) that match all the fields between {} but am not able to get it to work for fields between double {{}} and ignore if only single curly bracket from one or both sides


Solution

  • Use this: {{([^{}]+)}} This will make sure that whatever we are getting will be between {{}}