Posted By

adrianparr on 04/29/10


Tagged

regex email valid format pattern regexp address as3


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

socialflasher
Nikolai
tspitzr


AS3 Checks a String to see if it is a Valid Email Format


 / Published in: ActionScript 3
 

  1. var inputEmail:String = "[email protected]";
  2. trace("inputEmail: "+inputEmail);
  3. trace("isValidEmailAddress: "+isValidEmailAddress(inputEmail));
  4.  
  5. function isValidEmailAddress($str:String):Boolean {
  6. return (($str == findValidEmailAddress($str)) ? true : false);
  7. }
  8.  
  9. function findValidEmailAddress($str:String):String {
  10. var pattern:RegExp = /\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b/gi;
  11. var result:Object = pattern.exec($str);
  12. return ((result == null) ? "" : result[0]);
  13. }

Report this snippet  

You need to login to post a comment.