Java se Regular expression two: match

Source: Internet
Author: User
Tags java se

Package Demo.regex;import java.util.regex.pattern;/* Regular expression: Match */public class Regexmatchesdemo {//Match mobile phone number//13xxxxx; 15xxxxxx;18xxxxxxpublic static void Checkphone (String string) {System.out.println (Pattern.matches ("1[358]\\d{9}", string));} Match Mailbox/* (0) can only be QQ mailbox/gmail mailbox/outlook Mailbox/163 mailbox One (1) Letter beginning, (3) User name part: can only be letters or numbers, (4) User name part: Length 3 to 18, (5) cannot end with Dot, minus or underscore, You cannot have two consecutive or two dots, minus, or underscore */public static void Checkemail (String email) {System.out.println (Pattern.matches ("[A-za-z]{1 ,}[a-za-z0-9]{2,17}@ (qq|gmail|163) {1}\\.com ", email));} public static void Checkphonetest () {Checkphone ("1345654647");// Falsecheckphone ("13456546470");//truecheckphone ("1745654647b");//falsecheckphone ("19456546479");//false}public static void Checkemailtest () {Checkemail ("[email protected]");//falsecheckemail ("[email protected]");// Falsecheckemail ("[email protected]");//falsecheckemail ("[email protected]");//truecheckemail ("[Email  protected] ");//true}public static void Main (STRing args[]) {//checkphonetest (); Checkemailtest ();}} 

  

Java se Regular expression two: match

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.