I think it goes without saying that we all want to be regular expression hipsters like Ben Nadel ... maybe it's just me? Anyway, there have been many occasions when a regular expression would have been the best tool for the job, but I wimped out and went with more cumbersome string manipulations with code. For a recent messaging system using templates, I started down that road but, luckily found a compelling reason to force myself to use the ActionScript RegEx class.
So the quick skinny is that I have a template with placeholders that I need to substitute completely before moving on. For the purposes of discussion, the reasons for the system will be unexplored and I'll try to leave everything simple enough to allow easy re-purposing.
The placeholder for the substitution needs to be fairly unique so that we don't collide with something that ought to be displayed. In this case, we'll denote all of the substitution values with the following form: