Using a regular expression to determine whether a string contains a valid email address format : Email Address « Regular Expressions « Flash / Flex / ActionScript






Using a regular expression to determine whether a string contains a valid email address format

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var sEmail:String = new String("someone@someserver.com");
        var reEmail:RegExp = new RegExp("^([\\w\\-\\.]+)@(([\\w ;\\-]{2,}\\.)+[\\w\\-]{2,3})$");
        trace(reEmail.test(sEmail));
    }
  }
}

        








Related examples in the same category

1.Determining whether a string contains a valid email address format