Skip to content

Instantly share code, notes, and snippets.

@hiddentrak
Created August 19, 2010 19:09
Show Gist options
  • Save hiddentrak/538635 to your computer and use it in GitHub Desktop.
Save hiddentrak/538635 to your computer and use it in GitHub Desktop.
//regex that finds and replaces tokens in a string
public function replaceTokens(str : String,paramObj : Object) : String {
//token structure ${tokenName}
var myRegEx : RegExp = /\$\{([a-zA-Z0-9]+)\}/g;
return str.replace(myRegEx, function():String {
return (paramObj[arguments[1]]) ? paramObj[arguments[1]] : "";
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment