Determining whether a string contains a valid email address format : Email Address : Regular Expressions Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Regular Expressions » Email Address »

 

Determining 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 bValidEmail:Boolean = true;
        var nAmpIndex:int = sEmail.indexOf("@");
        var nDotIndex:int = sEmail.lastIndexOf(".");
        if(nAmpIndex == -|| nDotIndex == -1) {
          bValidEmail = false;
        }
        if(!(nAmpIndex > 0)) {
          bValidEmail = false;
        }
          if(!(nDotIndex > nAmpIndex)) {
        bValidEmail = false;
        }
        if(!(nDotIndex < sEmail.length - 1|| !(nDotIndex > nAmpIndex + 1)) {
          bValidEmail = false;
        }
        trace(bValidEmail);
        
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Regular Expressions
» Email Address