Class String provides several methods for performing regular expression operations.
3 methods provides by strings are:
- s.matches("regex")
- s.split("regex")
- s.replace("regex", "replacement")
matches() evaluates true if the WHOLE string can be matched with string s.
split() creates array with substrings of s divided at occurrence of "regex". "regex" is not included in the result.
replace() replaces "regex" with "replacement.
Basic regex expressions with String.matches()
No comments:
Post a Comment