public class RegixTest {
public static void main(String[] args) {
System.out.println(isValidString("0000aa"));
}
public static boolean isValidString(String testString){
String regEx = "[0-9a-fA-F]{6}";
Pattern pat = Pattern.compile(regEx);
Matcher mat = pat.matcher(testString);
if(mat.matches()){
return true;
}else{
return false;
}
}
}
这是一个匹配6位十六进制的正则表达式写法
原文链接:https://www.f2er.com/regex/361417.html