In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

re: regular expression escaping

Get Adobe Flash player
by makc3d 27 Apr 2011

    Talk

    wh0 at 28 Apr 2011 04:43
    thanks, I'm going to go with /[\\]u0064/
    Embed
/**
 * Copyright makc3d ( http://wonderfl.net/user/makc3d )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/672D
 */

// forked from wh0's regular expression escaping
package {
    import com.actionscriptbible.Example;
    import flash.utils.describeType;
    public class FlashTest extends Example {
        
        public function FlashTest() {
            // Use a regular expression to find \u0064
            
            // something like this:
            var re:RegExp = /\\[u]{1}0064/;
            
            trace('source: ' + re.source);
            
            var str1:String = '\\u0064';
            trace('test string 1: ' + str1);
            trace('should be \\u0064: ' + re.exec(str1));
            var str2:String = 'foo5bar';
            trace('test string 2: ' + str2);
            trace('should be null: ' + re.exec(str2));
        }
        
    }
}