In a large String, some words wrap by {{ }} in three ways:
1. {{some words}}
2. {{#some words}}
3. {{/some words}}
I need a regex that just converts {{some words}} to {{{some words}}}. Is there any solution?
>Solution :
If I understand correctly you want to exclude some {{ }} patterns from adding these extra braces.
You can use [^#/] to match any character that is not # and / and use that in the overal regular expression:
let text = "{{hello}} {{#hello}} {{/hello}} {{world}} {{#world}} {{/world}}";
let result = text.replace(/\{\{[^#/].*?}}/g, "{$&}");
console.log(result);
.*?matches any character (except newline) in a lazy manner, i.e. it will stop matching when}}is encountered.$&represents the complete matched string