I'm trying to make a regex to extract any word (alphanumeric) between curly brackets as in the example bellow:
Hi {{ name }}, your full name is {{ concat first_name last_name }}
The conditions are:
- if the content inside contains only a sequential alpha_numeric, that means it is a variable and should be extracted.
- if the content inside contains more than one alpha_numeric separated by space, that means the first occurrence is a function name and should be ignored, but the remaining arguments (function arguments) should be extracted.
- each function argument is separated by space.
- each variable name can contain more than one word, but each word in the variable name should be connected using a separator, e.g: first_name
- the function arguments can have one or many arguments and each argument should be matched.
So the result for the first example should be:
name, first_name, last_name.
This is what I tried: \{\s*\{\s*([^\}\/\s]+)\s*\}\s*\}
But it only covers the first scenario.
Another example:
"Key": "price_change_manager.msg2 {{ message }}"
value": "{{ username }} plan to {{formatCurrence new_price currency old_price }}"
Should match: message, username, new_price, currency, old_price.