RegExp Validation

The below function validates the email ID string using regular expression.

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

//e-mail option 2:

/[a-zA-Z0-9!$&*.=^`|~#%’+\/?_{}-]+@([\w_-]+\.)+[a-zA-Z]{2,4}/;

//URL:

/(https?|ftp|svn)(:\/\/[\w-_.:;!?~*\'()\/\@&=+\$,%#]+)/;

//Color:

/#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})/;

//String Quote:

/(“|’)(.+)?\1/;

IP evaluation:

var ipPattern:RegExp = /\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/;

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: