I have in javascript/jQuery a string whose content is set via a settings field by the user. The setting invites users to use predefined shortcodes like: [firstname] and [email]. So the content of the javascript string may be: "Hi [firstname], thanks for submitting the form! We sent a confirmation email to [email]. Thanks"
How do I in javascript/jQuery replace these shortcodes with javascript variables so it ends up being something like:
var userSetting = 'Hi ' + firstname + ', thanks for submitting the form! We sent a confirmation email to ' + email + '. Thanks';
Thanks for your help! I don't believe this is a duplicate because I am not trying to do a simple string replacement, I am trying to replace a string with a predefined variable.