Automation _ Continuous Integration ___java___ Regular expressions

Source: Internet
Author: User

One, the code is as follows
Package Com.wujianbo.five;import Java.util.regex.matcher;import Java.util.regex.pattern;public class Demo01 {public static void Main (string[] args) {//TODO auto-generated method stubstring phone= "13541433525"; String phoneex= "^1[387]\\d{9}"; Pattern pattern= Pattern.compile (Phoneex);//compile regular expression Matcher matcherphone= pattern.matcher (phone); System.out.println (Matcherphone.matches ());}}

Package Com.wujianbo.five;import Java.util.regex.matcher;import Java.util.regex.pattern;public class Demo01 {public static void Main (string[] args) {//TODO auto-generated method stub//string phone= "13541433525";//string phoneex= "^1[387 ]\\d{9} ";//pattern pattern= Pattern.compile (Phoneex);//compile regular expression//matcher matcherphone= pattern.matcher (phone);// System.out.println (Matcherphone.matches ()); String telephone= "0512-85121234"; String telephoneex= "^0\\d{2,3}-[856]\\d{6,7}"; System.out.println (Pattern.compile (Telephoneex). Matcher (telephone). matches ());}}

Package Com.wujianbo.five;import Java.util.regex.pattern;public class Demo03 {public static void main (string[] args) {// TODO auto-generated method stub//string email= "[email protected]"; String email= "[email protected]";        String emailex= "[a-za-z0-9{1,}@ ((a-za-z0-9-*) {1,}\\.) {1,3} [a-za-z\\-] {1,} "; String emailex= "[A-za-z0-9]{1,}@[a-za-z0-9]{1,}. [A-za-z0-9] {1,}. [A-za-z0-9] {1,}$ "; System.out.println (Pattern.compile (Emailex). Matcher (email). matches ());}}

Package Com.wujianbo.five;import Java.util.regex.matcher;import Java.util.regex.pattern;public class Demo02 {public static void Main (string[] args) {//TODO auto-generated method stubstring source= "<input name= ' verify ' value= ' 3334DFAF Addfa ' type= ' hidden '/> '; String regex= "(value= ') (. +) (' type)"; String tmp= ""; Pattern p= Pattern.compile (regEx); Matcher m= p.matcher (source);//system.out.println (M.find ()); if (M.find ()) {tmp= m.group (2); SYSTEM.OUT.PRINTLN (TMP);}}}

Package com.wujianbo.five;

Import Java.util.regex.Matcher;

Import Java.util.regex.Pattern;

Public class Demo02 {

public &NBSP; static &NBSP; void  main (string[] args ) {

// TODO auto-generated Method Stub

String Source = "<input name= ' verify ' value= ' 3334dfafaddfa ' type= ' hidden '/> ' ;

String regEx = "(value= ') (. +) (' type)" ;

String tmp = "" ;

P Attern p = Pattern. compile ( regex );

Matcher m = P . Matcher (source);

System.out.println (M.find ());

if (m. Find ()) {

tmp = m . Group (2);

System. out . println (tmp);

}

}

}

Automation _ Continuous Integration ___java___ Regular expressions

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.