Using Regular Expressions with String.matches()
by, 04-26-2012 at 06:44 PM (504 Views)
Built in support is provided by Strings present in Java for the regular expressions. There are 3 built in methods present in Strings for regular expressions. For example: replace(), split() and matches().
There is no optimization of methods for performance. Classes will be used later on, which are performance optimized.
s.matches("regex"): Evaluates if "regex" matches s. Returns only true if the WHOLE string can be matched
s.split("regex"):C reates array with substrings of s divided at occurance of "regex". "regex" is not included in the result.