I am coding a simple template function in javascript.
I have a great template loading, now this is the part when I need to parse the contents for placeholders.
template example:
{{name}} is {{age}}
They are dynamic, so ideally I want to use a regular expression to match and replace placeholders based on their names, for example.
{{name}} should be replaced by content loaded into a javascript array, for example.
data.name data.age
This is my regular expression: /\{\{(.*?)\}\}/
This works fine, but after a lot of searching, I cannot find a specific way to repeat each regular expression match.
Thank you in advance
source share