I believe this should work, it worked for me...
code:
strMyNewPSM = strMyNewPSM.replace(/\[c=([1-4]?\d|5[0-4])\]/gi, "·\$$$1")
strMyNewPSM = strMyNewPSM.replace(/\[\/c\]/gi, "·\$");
strMyNewPSM = strMyNewPSM.replace(/^\s+/g, "");
And no lopes at all
I had to search how to get the '$'-sign as the replace text, because $1-$9 are used for backreference... (putting part of the matched text in the replaced text)
If want/need to know how it works, just ask me on WLM sometimes...