Regular Expression Reference on a Mouse Mat * Java Training
POSIX details * Perl details * Java details
Java Regular Expressions
Up to and including Java2 release 1.3, the only regular expression handlers available were third party supplied. As from Java2 1.4, a regex class java.util.regex was added to the main Java distribution, and it's that regular expression handler that we provide information on on this page.
The above list shows the most commonly used elements of Java regular expressions. It is not exhaustive.
In order to use a Regular Expression in Java 1.4 a regular expression, specified as a String, must first be compiled into an instance of the class Pattern. The resulting pattern can then be used to create a Matcher object that can match arbitrary character i sequences against the regular expression. All of the state involved in performing a match resides in the matcher, so many matchers can share the same pattern.
A typical invocation sequence is thus
Pattern p = Pattern.compile("a*b");
Matcher m = p.matcher("aaaaab");
boolean b = m.matches();
Back to Regular Expression Home Page
Jump to Elements of a regular expression
Order a Regular Expression Mousemat for £4.95 inclusive
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho