❮ Previous Next ❯

Java Regular Expression Email Validation

Java Regular expression program to represent all valid mail ids:

[a-z][A-Z][0-9][a-z][A-Z][0-9_.]* @ [a-zA-Z0-9] + ([.][a-zA-Z]+)+

Only gmail id is:

[a-zA-Z0-9] [a-zA-Z0-9_.]* @ gmail[.]com

Java Regular expression program to check whether a given mail id is valid or invalid mail id.

import java.util.regex.*;
class RegexDemo7
public static void main(String[] args)
Pattern p=Pattern.compile("[a-zA-Z0-9][a-zA-Z0-9_.]*@[a-zA-Z0-9]+([.][a-zA-Z]+)+");
Matcher m=p.matcher(args[0]);
if(m.find() && m.group().equals(args[0]))
System.out.println("valid mail id");
System.out.println("invalid mail id");
1st run : java RegexDemo7 trilochan4u@gmail.com
valid mail id
2nd run : java RegexDemo7 trilochan4u
invalid mail id
❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved