我有一個要求,以確保該字符串只有字母數字或一組字符,如+(),'。 - = 我試着像正則表達式來驗證alpahanumeric或一組特殊字符
String regex = "([a-zA-Z0-9]+)|([\\'|\\()|\\+|\\,|\\-|\\.|\\="]+)";
System.out.println("Regex : " + regex);
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
if (matcher.matches()) {
System.out.println("Match");
} else {
System.out.println("Not Matching");
}
的Bt它不工作,誰能幫助我,請提前
感謝
語法着色清楚地表明你有parenthesing問題。 –