Hi,
Regex API is used for
pattern matching against pattern specified by the user by regular expressions.
For instance, you need to avoid entering special characters by the end user for any field like First Name or Last Name, then you may make use of
java.util.regex API.
Refer
here for its API.
For example:
Pattern pattern = Pattern.compile("!@#$%"); //
String which you want to restrict
Matcher matcher = pattern.matcher("stringToBeMatched"); // String that needs to be matched (may be entered by user for First Name)
matcher.find(); // returns true if string matched else false is returned
Perform action as per the output is returned.
Thanks,
Ashwini Kashyap | www.infocepts.com