Working with Regular Expressions
/([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}/
There are two way to create regular expression instance.
var p1:RegExp = /bob/i; var p2:RegExp = new RegExp("bob", "i");
The following characters have special meaning in regular expressions.
^ $ \ . * + ? ( ) [ ] { } |
RegExp class
The RegExp class has two methods, exec() and test(). The test() simply returns true or false if it contains a match for the regular expressions. The exec() returns an array with the matching substring. The array includes an index property that indicates the index position of the start of the substring match.
Flags
The i flag means the search is not case-sensitive. The seach() method finds only one match and returns its starting index position even if the g flag is set in the regular expression, though the exec() method returns multiple substrings to be matched.
var pattern:RegExp = /the/i; var str:String = "The"; trace(str.search(pattern)); // 0;