I have a string that looks like this:
var minLength = 3;
var mystring = "This field must be {{minLength}} characters"
I’m curious of a good way to to detect the presence of {{ … }} and replace the contents with the minLength variable. As you can probably expect there are a number of different variables like minLength, maxLength, etc. I’ve tried regex but can’t seem to get it to work.
demo
This way you can add more than one value to be replaced, you just have to add it do
valuesand addgto the regex.demo