A RegEx can be used in a string.replace() command or other locations.
RegEx in ActionScript, like XML, has two constructors: with quotes or without (examples from Adobe’s RegEx class reference):
var pattern1:RegExp = new RegExp("test-\\d", "i");
var pattern2:RegExp = /test-\d/i;
Because these are constructors, they create a new RegEx invisibly, so can be used as function parameters (as in string.replace()) without further declaration:
var str:String = "test-12345"; str.replace("test-(\\d)", "replaced-\\1"); str.replace(/test-(\d)/i, "replaced-\\1");