zoukankan      html  css  js  c++  java
  • 【自动化__持续集成】___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= "dengqiang@woniuxy.com.cn";
    		String email= "dengqiang@woniuxy.com.cn";
            //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);

    }

     

    }

     

    }

  • 相关阅读:
    zz解读NoSQL技术代表之作Dynamo
    愚蠢且能干
    Schema 验证和 DTD 验证
    Office Addin (VSTO) Performance Tips & Tricks
    提高 .NET 应用 XML 处理性能的几点开发经验(转载)
    C# 实现对XML文件的基本操作(创建xml文件,增、删、改、查 xml节点信息)zz
    XML/XSLT/XPATH
    Linux下基于DNS的多机均衡负载的实现
    Linux 上的高可用中间件,第 3 部分: IBM LoadLeveler
    Creating Web Services using Apache
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7492167.html
Copyright © 2011-2022 走看看