Select a regular expression syntax in the topmost choice menu.
Type a regular expression in the first text field. Then in
the Search Input text area, enter text that you want to
search. Click the Search button to search the input text.
The results will appear in the Search Results text area.
The Reset button will clear the regular expression, input,
and result text.
There are two choice menus that affect the regular expression
search. The contains() item causes the
contains()
method of the PatternMatcher interface to be
used to perform the search. This search is done in a while loop,
finding all pattern matches occuring within the input. The
matches() item causes the matches()
method of
the PatternMatcher interface to be used to perform the search. The
matches()
method only tests if all the input
EXACTLY matches the regular expression. It does not check
to see if there is a match somewhere inside the input. That is
what the contains()
method is for. This is sometimes
a point of confusion for users who have tried other packages. In
Jakarta ORO, matches()
is used to find exact matches,
and contains
is used to find a match contained in the
input.
The Case Sensitive and Case Insensitive choice items
are self-explanatory. Case Sensitive causes the regular
expression to be compiled with case sensitivity enabled. Case
Insensitive causes the regular expression to treat upper and
lower case characters the same.
The Search Results text area will display all the matches
found in the input when the contains() choice item is
selected. It will also display what the parenthesized subgroups
of a regular expression matched. When the matches() choice
item is selected, only whether or not the input exactly matched
the pattern is indicated.
Please note that if you don't enter anything for a regular
expression, it will be compiled as an expression matching a
zero-length string (the null string), which will match before and
after every character in the input.