How do I search a string in Javascript for all instances of [SM_g]randomword[SM_h]. and replace them all with [SM_g]randomword.[SM_h].
I'd also like to do this with commas. For example - I need to be able to turn [SM_g]randomword[SM_h], into [SM_g]randomword,[SM_h].
Here is my code so far:
const periodRegex = /\[SM_g](.*?)\[SM_h](?:[.])/g;
string_afterregex - string_initial.replace(periodRegex, /*I don't know what goes in here*/)