Maybe I got confused by your saying that $$ was confusing you. (To me, it's either a special variable in perl and bash: the current process's PID.. or a $ at the end of the line in regexp).
See? Even more reasons it was a bizarre choice! (I wonder which predates which?) As the character is everywhere. Tags should be chosen for reasonable uniqueness, ease of parsing and ease of remembering. Arg. I would love to know what the original latex people were thinking... Double dollar signs, ok, but along with single dollar sign tags too? A recipe for disaster.
The problem as you might imagine went something like this:
"Lor$em ipsum dolor sit amet, consectetur adipisicing elit, sed $4.95 do eiusm$$od te$$mpor incididunt $$ut$$ labo$re$ et dolore ma$$gna$$ aliqua. Ut enim ad minim veniam, $quis$ nostrud exe$rcitati$on ullamco$ laboris $nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit $14.95 on sale in vo$$lupta$$te velit $esse$ cillum dolore eu f$ugi$at nulla pariatur. Excepteur sint occaecat cupidatat non proide$$nt, s$$unt in culpa qui officia deserunt mollit $$anim$$ id est laborum."
How the hell are you supposed to tell what is inside what tag? And which are just prices? Virtually impossible.
This wouldn't work for both (I expect I know why):
/\${1}([\s\S]*?)\${1}|\${2}([\s\S]*?)\${2}/gm
(the / /gm are wrappers for the regexp in javascript, the m and g specify multiline and global)
But:
/\${2}([\s\S]*?)\${2}/gm
works just fine for double tags. I just did not want to try and figure out a way to do it, I don't know them well enough. Then, it would pretty much require escaping dollar signs in the wiki text... I don't like that I want it to all work naturally.
Truth is, there are 2 'levels' of regular expressions that I know. Perl and sed use Extended regexp.
Javascript is using extended as of v1.5 I'm pretty sure. I've got extended regexps in this thing tested on all major browsers, so it must be. I expect there are a few fiddly differences here and there though.