New member
- Joined
- Feb 2, 2023
- Messages
- 7
- Thread Author
- #1
Recently I came across one issue where I need to change the double curly braces with triple curly braces ,
The below example could clarify the need further,
let mystring = '{{Hello Tom}} , {{How are you doing today}}'
I need to change the above string and replace "{{" and "}}" with "{{{" and "}}}" respectively.
Currently I am using regex as below,
let output_string = mystring.replace(/{{/g, "{{{").replace(/}}/g, "}}}")
At the first execution its working fine and I got the desired output as '{{{Hello Tom}}} , {{{How are you doing today}}}' , when the next execution happen , it changed to 4 curly braces like below,
Output after second execution,
'{{{{Hello Tom}}}} , {{{{How are you doing today}}}}'
Its keep on increasing the curly braces whenever event is repeated.
I just want to replace 2 curly braces with 3,not any further
How can I Achieve this ???
The below example could clarify the need further,
let mystring = '{{Hello Tom}} , {{How are you doing today}}'
I need to change the above string and replace "{{" and "}}" with "{{{" and "}}}" respectively.
Currently I am using regex as below,
let output_string = mystring.replace(/{{/g, "{{{").replace(/}}/g, "}}}")
At the first execution its working fine and I got the desired output as '{{{Hello Tom}}} , {{{How are you doing today}}}' , when the next execution happen , it changed to 4 curly braces like below,
Output after second execution,
'{{{{Hello Tom}}}} , {{{{How are you doing today}}}}'
Its keep on increasing the curly braces whenever event is repeated.
I just want to replace 2 curly braces with 3,not any further
How can I Achieve this ???