自动化__持续集成___java___正则表达式

Posted 18513757531

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动化__持续集成___java___正则表达式相关的知识,希望对你有一定的参考价值。

一、代码如下

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);//编译正则表达式
		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);//编译正则表达式
		//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 stub
		String source= "<input name=‘verify‘ value=‘3334dfafaddfa‘ 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 static void main(String[] args) {

// TODO Auto-generated method stub

String source= "<input name=‘verify‘ value=‘3334dfafaddfa‘ 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);

}

 

}

 

}

以上是关于自动化__持续集成___java___正则表达式的主要内容,如果未能解决你的问题,请参考以下文章

自动化__持续集成___java___继承

自动化__持续集成___java___finally

自动化__持续集成___java___List

自动化__持续集成___java___取值范围

自动化__持续集成___java___数据类型转换

自动化__持续集成___java___字符串