COPYRIGHT AND LICENSE
What is a regular expression?
Perl5 regular expressions
Difference between matches() and contains()
Searching an InputStream
Package API reference (javadoc generated)
OROMatcher TM defines a basic set of interfaces which are implemented by its pattern matching classes. This facilitates the addition of new pattern matching classes supporting different grammars. The basic use of the package consists of creating a PatternCompiler instance to compile your regular expressions and compiling your regular expression to produce a Pattern instance. You then create a PatternMatcher instance to perform pattern searches using the Pattern instance. Pattern matches are accessed through MatchResult instances.
In a non-concurrent program you should only need to create one
PatternCompiler and one PatternMatcher instance to compile all
your regular expressions and do all your matching. It is wasteful
to create a new PatternCompiler and PatternMatcher every time you
need to compile a patten or search for a match. In a concurrent
program we recommend using separate PatternCompiler and PatternMatcher
instances for each thread, because synchronization overhead is high
The Pattern interface allows multiple representations of a regular
expression to be defined. In general, different regular expression
compilers will produce different types of pattern
representations. Some will produce state transition tables derived
from syntax trees, others will produce byte code representations of an
NFA, etc. The Pattern interface does not impose any specific internal
pattern representation, and consequently, Pattern implementations are
not meant to be interchangeable among differing PatternCompiler and
PatternMatcher implementations. The documentation accompanying a
specific implementation will define what other classes a Pattern can
The PatternMatcher interface defines three main types of methods:
The MatchResult interfaceThe MatchResult interface allows PatternMatcher implementors to return results storing match information in whatever format they like, while presenting a consistent way of accessing that information. A MatchResult instance contains a pattern match and its saved groups. You can access the entire match directly using the group(int) method with an argument of 0, or by the toString() method which is defined to return the same thing. Saved groups can be accessed by calling the group(int) method with the appropriate group index. It is also possible to obtain the beginning and ending offsets of a match relative to the input producing the match by using the beginOffset(int) and endOffset(int) methods. The begin(int) and end(int) methods are useful in some circumstances and return the begin and end offsets of the subgroups of a match relative to the beginning of the match.
You should look at the matchResultExample.java example program to see how to use all of the MatchResult methods.
Copyright © 1997 ORO, Inc. All rights reserved. Original Reusable Objects, ORO, the ORO logo, and "Component software for the Internet" are trademarks or registered trademarks of ORO, Inc. in the United States and other countries.
Java is a trademark of Sun Microsystems. All other trademarks are the property of their respective holders.