标签:blog java ar div log c amp r as
package everyDayPratise; import java.util.regex.Pattern; public class RegexExample { public static void main(String[] args) { // 1. 美国身份证号 // 999-99-9999 // 999999999 Pattern p1 = Pattern.compile("[0-9]{3}\\-[0-9]{2}\\-[0-9]{4}"); Pattern p2 = Pattern.compile("\\d{3}\\-\\d{2}\\-\\d{4}"); Pattern p3 = Pattern.compile("[0-9]{3}\\-?[0-9]{2}\\-?[0-9]{4}"); Pattern p4 = Pattern.compile("\\d{3}\\-?\\d{2}\\-?\\d{4}"); // 2. 美国车牌号 // 4321AW Pattern p5 = Pattern.compile("\\d{4}[A-Z]{2}"); // 3. x开头除外的的所有单词 Pattern p6 = Pattern.compile("[^x][a-z]*"); } }
标签:blog java ar div log c amp r as
原文地址:http://www.cnblogs.com/wyqAtom/p/3961707.html