regular expression expalanation i need

regular expression expalanation i need

hi......... here is my code could explain it

<html>
<script language = "Javascript">
function checkEmail() {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value))
{
document.write("You have entered valid email.");
return true;
}
return false; 
}


function ValidateEmail(){
var emailID=document.form.email;

if ((emailID.value==null)||(emailID.value=="")){
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (checkEmail(emailID.value)==false){
emailID.value=""
alert("Invalid Email Adderess");
emailID.focus()
return false
}
return true
}
</script>
<form name="form" method="post" onSubmit="return ValidateEmail()">
Enter an Email Address : <input type="text" name="email" size="30"><br>
<input type="submit" name="Submit" value="Submit">
</form>
</html>`print("code sample");`
View Answers

May 25, 2012 at 12:58 PM

<html>
<head>
<title>Email validation using regex</title>
<script type="text/javascript">
    function validate() {
        var email = document.getElementById("email").value;
        var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
        if (emailPattern.test(email)) {
            alert("Email Id: " + email);
            return true;
        } else {
            alert("Email Id is not valid!");
            return false;
        }
    }
</script>

</head>
<body>
<h2>Validating Email Id..</h2>
Email Id :
<input type="text" name="email" id="email" />
<input type="submit" value="Submit" onclick="validate();"/>
</body>
</html>

Description: Email pattern is like [email protected]. you have to check the pattern of combination of these two. Sometimes space is also included in it.

         In pattern /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/
            /../(forward slashes) is used to quote your regular expression.
              ^ shows beginning of string.
              [..] matches any letter enclosed with in.
              + shows that preceding character come 1 or more times.
              \. Shows that \ will treat . as a literal. 
              {2,4} shows the range that content having length between 2 to 4.
              $ is used for ending the string.
            test() method takes one argument and check that to the pattern.









Related Tutorials/Questions & Answers:
regular expression expalanation i need
regular expression expalanation i need  hi......... here is my code could explain it <html> <script language = "Javascript">... your regular expression. ^ shows beginning of string
javascript regular expression
javascript regular expression  i need a regular expression code for JavaScript
Advertisements
Regular expression
Regular expression  how i write a regular expression for a pattern which present in between
Regular expression
Regular expression  I have the regular expression : var x=/(^\d+$)/ which allows only numbers. It does not accept character, decimals. However it accepts zero. I want an expression that takes numbers(no decimals)except zero
regular expression for phone number
regular expression for phone number  Hi, i need the regular expression code for phone number in PHP. Thanks.   PHP - regular expression code for phone number \+?([0-9]{2})-?([0-9]{3})-?([0-9]{6,7
java regular expression
java regular expression  hi i need java expression which allows all characters with minimum 2 characters and maximum 20 characters in answers field after selecting security questions
Regular expression
Regular expression  how i extract string Coalition of civil society organizations and CSOs from string:- CSOs : What happening in Yemen is political crisis SANA'A, May 16 (Saba)- Coalition of civil society organizations (CSOs
Regular expression
Regular expression  can some one explain how below regex works, ndmurl1=${ndmurl#${ndmurl
A regular expression contains another regular expression - PHP
A regular expression contains another regular expression   Please explain how it works in PHP... RegEX1 = "a.*b"; RegEx2 = "a1.*b"; Thanks
regular expression for special characters
regular expression for special characters  How to find out regular expression for special characters
Regular Expression for removing XML Tags
after applying regular expression is only "How are you".Need to remove all XML...Regular Expression for removing XML Tags  Hi, Good Afternoon.I want a Regular expression in java which is removing the XML Tags in the specified
split string with regular expression
split string with regular expression  How to split string with regular expression in Java
Regular expression in c++{MFC}
Regular expression in c++{MFC}  Hi ALL, I want to build a regular expression in c++{MFC} which validates the URL. The regular expression must... of %5C & %2F character. How can we develop a generic Regular Expression
using regular expression
using regular expression  How can we extract string 'abc.com ' from a string http://[email protected] using regular expression of php
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
Regular expression contains character - PHP
Regular expression contains character  A PHP script that can check if the regular expression contains character
Regular Expression Help Help HELP!!!!
Regular Expression Help Help HELP!!!!  HI all I am very new to java... = "International Students 1"; So i need to extract only the "international Students", i...","hotmail.com"); so i need to extract"07001", "MR Harish Ram " and extract "M.RHarish
including index in java regular expression
including index in java regular expression  Hi, I am using java regular expression to merge using underscore consecutive capatalized words e.g.... from you is that is it possible using regular expression to avoid first word
What is regular expression beginning of line ?
What is regular expression beginning of line ?  Hi, I one of my Java program I have to write a program to find the beginning of a line and then replace the text using replaceAll() function of String. What is regular expression
Regular expression in PHP for email - PHP
Regular expression in PHP for email  can any one tell me how to write regular expression in PHP for email to retrieve all the valid email ID's from the email
PHPMYSQL REGULAR EXPRESSION - WebSevices
PHPMYSQL REGULAR EXPRESSION  Hello all, I have to read a file... ************************************************************************ I have write a following script.... ************************************************************************** When I check my match by echo had a right values.But
PHP Regular Expression
PHP regular expression allows programmer to perform various task like comparing, finding and replacing a particular type of strings. Using Regular... strings. PHP Regular expression also allows you to validate a email, phone
Regarding regular expression with swing - Swing AWT
Regarding regular expression with swing  Regular Expression for value that should be greater than 0.0 and less than 999.9 0.0 > value < 999.9 Please Check it, in cell editor in JTable to validate a particular
Regular Expression Search Program
Regular Expression Search Program       Regular Expression: Regular Expression is used to perform many... a matcher object which finds the character sequences for the regular expression
about regular expression - Java Beginners
about regular expression  Consider the grammar G: S -> ( L ) | a L -> L, S | S a) Eliminate the left-recursion from grammar G. b) Construct a recursive descent parser for G
Capturing Text in a Group in a Regular Expression
Capturing Text in a Group in a Regular Expression  ... the text in a group through the regular expression. Here, you can learn...; in the console output because the regular expression mentioned in the code detects
Phone number validation using regular expression
Phone number validation using regular expression  Explain phone number validation using regular expression in JavaScript.   phone = phone.replace(/[^0-9]/g, ''); if(phone.length != 10) { alert("not 10 digits
match string to regular expression - Objective C
match string to regular expression - Objective C  How to match string value to regular expression in objective c?   Use NSPredicate. See the example given below... NSString *searchString = @"loginStatus"; NSString
Java validate phone number using regular expression
Java validate phone number using regular expression In this tutorial, you will learn how to validate the phone number using regular expression. The user is allowed to enter a number in a specific range i.e., a number should only
Retrieving String by using Regular Expression
Retrieving String by using Regular Expression  ... the way to retrieve the String using Regular expression. For this we are going... and compiles the given regular expression into a pattern. Matcher m = p.matcher
Reset the matcher using regular expression
Reset the matcher using regular expression  ... the String using regular expression. For this we are going to make program named...:- String regex = ("\\w.+"):- Creating expression for text. Here "
Pattern resetting using regular expression
Pattern resetting using regular expression  ... the String using regular expression. For this we are going to make program named...):-Creating a pattern object and compiling the given regular expression
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
i need project
i need project  can u send online shoppin project 2 my mailid.   Please visit the following links: Struts2 Shopping cart JSP-Servlet Shopping cart
hello there i need help
hello there i need help  : i need to do a program like this: Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you... me with the codes and please explain to me how it works. i only need to use
Parsing a String into Paragraphs Using a Regular Expression
Parsing a String into Paragraphs Using a Regular Expression... how to parse the string into the paragraphs using regular expression in Java...;new Thread();   for(int i=0; i<=paras.length-1; 
Matching Zip code using regular expression
Matching Zip code using regular expression  ... code with the regular expression .For this we are going to make program named...;:-This is the regular expression use to match with Zip code.ADS_TO_REPLACE_1 matchZip("
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer n is written n! (pronounced â?? n factorialâ??) and is defined as follows: n!=n...=input.nextInt(); long num=m; for(int i=m;i>1;i
Getting the Indices of a Matching Group in a Regular Expression
Getting the Indices of a Matching Group in a Regular Expression... the regular expression in Java. This section explains some method or APIs which...;regular expression   Pattern pattern = Pattern.compile
Pointing and indicating matcher using regular expression
Pointing and indicating matcher using regular expression... the given regular expression into a pattern. String matcher[]={" ^","  ... to point the matcher and also indicate the index of the matcher using regular
Parsing Character-Separated Data with a Regular Expression
Parsing Character-Separated Data with a Regular Expression... for separation the word of the sentences through the given regular expression...; i < str.length; i++){   System.out.println(str[i
I need Spring 2.5 example.
I need Spring 2.5 example.  Hello, I am looking forward to learn Spring framework and hence I need Spring 2.5 and Spring 3.0 example.. Thanks
I need to develop a gui like this
I need to develop a gui like this  Hai Friends, I need to develop such a menu in my gui programs. The gui contains 1 text field.whenever the text... please help me   sorry goes through this link I need to develop like
How can we extract string 'roseindia.net ' from a string http://deepak@roseindia. net using regular expression of php?
://deepak@roseindia. net using regular expression of php?   How can we extract string 'roseindia.net ' from a string http://deepak@roseindia. net using regular expression of php
Match string using regular expression without Case sensitivity
Match string using regular expression without Case sensitivity... the way to match the String using regular expression. For this we are going to make... JAVA have regular expressions Regular expressions are in Java
Finding start and end index of string using Regular expression
Finding start and end index of string using Regular expression... the way for finding start and end index of the string using regular expression...):-Creating a pattern object and compiling  the given regular expression
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
i need help - Development process
i need help  hello, i need help regarding this program. public...()); } } } it is printing the result of ping in to a file,but if i want... the result in to the files,if i want to do this i must make my program running

Ads