We use Regex to match text, for example, follow
String str =".*" + s + ".*";
here - s user enters text
if(stringtext.matches(str .toLowerCase())){
return true;
}
The above code works fine when the user enters plain text.
but the user enters any regular expression character, for example, for example. (,},}, ^, $ etc. this gives java.util.regex.PatternSyntaxException: Unclosed group near index 5. (.
source
share