The package java.util.regex (new in J2SE SDK1.4, released in 2002) works in pretty much the same way as org.apache.regexp, but with minor syntactic differences in some advanced RE features and with a different mechanism for invoking compilation and matches. Instead of
RE r = new RE(patt);
if (r.match(line)) {
// line matches pattern ...
}
you would use:
Pattern r = new Pattern(patt);
if (r.matcher().matches(line)) {
// line matches pattern ...
}
The argument to matches() (or the matcher() constructor) must implement the new CharSequence interface, which is similar to the CharacterIterator defined in org.apache.regexp. The standard classes java.lang.String and java.lang.StringBuffer have been modified in JDK1.4 to implement this interface, and the new class java.nio.CharBuffer also implements this interface, potentially making it easy to scan a stream for a pattern.
If you have Java 2 Version 1.4, see the documentation for the java.util.regexp package.