Java Regular Expressions: Difference between revisions
Jump to navigation
Jump to search
Line 30: | Line 30: | ||
s.matches(...); | s.matches(...); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
While convenient in some cases, the String API also delegates to via the Pattern.matches() call. | |||
=Concurrent Usage Considerations= | =Concurrent Usage Considerations= | ||
{{Warn|Matcher instances are NOT thread safe, create a matcher per thread}} | {{Warn|Matcher instances are NOT thread safe, create a matcher per thread}} |
Revision as of 21:21, 29 July 2017
External
Internal
Overview
Regular expressions can be used in Java via the String API or java.util.regex API.
java.util.regex API
The general pattern for using regular expressions is the following:
Working code is available here:
java.langString API
String s = "...";
s.matches(...);
While convenient in some cases, the String API also delegates to via the Pattern.matches() call.
Concurrent Usage Considerations
Matcher instances are NOT thread safe, create a matcher per thread