Loop to HTML text, replace tags with another value

I am creating a custom message desktop app, that will enable people customize messages. I mean replace the tags in the message with data the have inserted in the app. But my java script code is unable to replace the tags with the data.

Here is an example of the custom message template:

Dear , You are cordially invited to our naming ceremony on the . We are glad to inform you that you have been employed by . We say congrats.
Thank you for opening an account with Great Bank, Your account number and password can be found below.
Account number :
Password :

Here is a good example: The name tags should be replaced by the name of the individual,etc.

I am using regex

here is the ouput: I get an unedited message

The output