URL Validation via RegExp


/ Published in: ActionScript 3
Save to your folder(s)

Founds this via http://www.flashcomguru.com/index.cfm/2009/2/17/regexp-validate-url


Copy this code and paste it in your HTML
  1. var url:String = "http://www.google.com";
  2. var regex:RegExp = /^http(s)?:\/\/((\d+\.\d+\.\d+\.\d+)|(([\w-]+\.)+([a-z,A-Z][\w-]*)))(:[1-9][0-9]*)?(\/([\w-.\/:%+@&=]+[\w- .\/?:%+@&=]*)?)?(#(.*))?$/i;
  3. trace(regex.test(url)); // returns true if valid url is found

URL: http://www.flashcomguru.com/index.cfm/2009/2/17/regexp-validate-url

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.