I wrote one regular expression for catching any special characters in the text.
regular expression: (?i)[$&+,:;=?@#|'<>.-^*()%!]
I am passing a text "Testing" but getting output that the text contains special characters. But as soon as i pass, "testing" with small "t", i am getting no error.. Can you please help ?
code:
String REGEX = "(?i)[$&+,:;=?@#|'<>.-^*()%!]";
String fieldValue="Testing";
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(REGEX);
java.util.regex.Matcher matcher = pattern.matcher(fieldValue);
if (matcher.find()) {
String strWarningMessage = "Field value cannot contain Special Characters";
System.out.println(strWarningMessage);
}
else
System.out.println("OK");
if, I hope it was a typo only when you posted the question. Isn't it?