The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Flash
  • ActionScript
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Flash
 ActionScript

  • Isocase Author 
    • 2161 
    • 0 
    • 4 
    [AS3] RegExp
    Fernando

    Last reply Feb 20 2008, 07:19 PM

    by Fernando

    Posted: Feb 18 2008, 01:55 PM

    by Isocase

     

I am trying to write out a RegExp pattern to validate an e-mail. I have googled but can’t seem to find a definite answer but what characters/symbols are not allowed in a valid email address?

Is RegExp the way to go to validate an email format? I started off using the below way, but then started looking into RegExp:

[AS]
function validateEmail( email:String ):Boolean
{
  var i:int = -1;
  var n:int = email.length;
 
  if( n <= 6 )
  {
      return false;
  }

  var invalidChar:String = “~^*|,\”:<>[]{}`\’;()&$#%”;
 
  while( ++ i < n )
  {
      if( invalidChar.indexOf( email.charAt( i ) ) != -1 )
      {
        return false;
      }
  }
 
  return true;
}
[/AS]

  4 REPLIES
 
Isocase Author 
1  
Isocase

Did some research and I was finally able to find information on wikipedia. Here is the URL if anyone ever needs to know this information

http://en.wikipedia.org/wiki/E-mail_address

  • 18 February 2008 04:08 PM
  •  
Fernando
2  
Fernando

[as]function isValidEmail(email:String):Boolean {
  var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
  return emailExpression.test(email);
}[/as]

[as]trace (isValidEmail(“user@ultrashock.com”)); // true
trace (isValidEmail(“test@@tester.com”)); // false[/as]

  • 18 February 2008 05:52 PM
  •  
Isocase Author 
3  
Isocase

Thanks Fernando

I was wondering and did some research but couldn’t find the answer I was looking for. In AS3 how processor intensive is using RegExp compared to using substring or something like that.

Example:

Lets say I am building a form and I want to remove white space after the subject. Would it be best to use a RegExp or just loop through the string until it finds the space then use substring to shorten?

  • 20 February 2008 06:50 PM
  •  
Fernando
4  
Fernando

RegExp is a hell lot faster than a substring way of doing smth.

  • 20 February 2008 07:19 PM
  •  
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 779  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,728  Assets
  • Profiles 282,751  Members
  • Topics 93,776  Topics
  • Blog 4  Blog
  • Facebook 1,679  Facebook
  • Twitter 1,163  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sat, February 11, 2012 - 18:56:16