|
Jakarta-ORO 2.0.6 API: Class Util
org.apache.oro.text.regex
|
Field Summary | |
static int |
SPLIT_ALL
A constant passed to the split() methods
indicating that all occurrences of a pattern should be used to
split a string. |
static int |
SUBSTITUTE_ALL
A constant passed to the substitute()
methods indicating that all occurrences of a pattern should be
substituted. |
Method Summary | |
static void |
split(java.util.Collection results,
PatternMatcher matcher,
Pattern pattern,
java.lang.String input)
Splits up a String instance and stores results as a
Collection of all its substrings using a regular expression
as the delimiter. |
static void |
split(java.util.Collection results,
PatternMatcher matcher,
Pattern pattern,
java.lang.String input,
int limit)
Splits up a String instance and stores results as a
List of substrings numbering no more than a specified
limit. |
static java.util.Vector |
split(PatternMatcher matcher,
Pattern pattern,
java.lang.String input)
Deprecated. Use split(Collection, PatternMatcher, Pattern, String) instead. |
static java.util.Vector |
split(PatternMatcher matcher,
Pattern pattern,
java.lang.String input,
int limit)
Deprecated. Use split(Collection, PatternMatcher, Pattern, String, int) instead. |
static java.lang.String |
substitute(PatternMatcher matcher,
Pattern pattern,
Substitution sub,
java.lang.String input)
Searches a string for a pattern and substitutes only the first occurence of the pattern. |
static java.lang.String |
substitute(PatternMatcher matcher,
Pattern pattern,
Substitution sub,
java.lang.String input,
int numSubs)
Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter. |
static int |
substitute(java.lang.StringBuffer result,
PatternMatcher matcher,
Pattern pattern,
Substitution sub,
PatternMatcherInput input,
int numSubs)
Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter. |
static int |
substitute(java.lang.StringBuffer result,
PatternMatcher matcher,
Pattern pattern,
Substitution sub,
java.lang.String input,
int numSubs)
Searches a string for a pattern and replaces the first occurrences of the pattern with a Substitution up to the number of substitutions specified by the numSubs parameter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SUBSTITUTE_ALL
substitute()
methods indicating that all occurrences of a pattern should be
substituted.public static final int SPLIT_ALL
split()
methods
indicating that all occurrences of a pattern should be used to
split a string.Method Detail |
public static void split(java.util.Collection results, PatternMatcher matcher, Pattern pattern, java.lang.String input, int limit)
String
instance and stores results as a
List
of substrings numbering no more than a specified
limit. The string is split with a regular expression as the delimiter.
The limit parameter essentially says to split the
string only on at most the first limit - 1 number of pattern
occurences.
This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:
In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern. In other words:
split(list, "/([,-])/", "8-12,15,18", Util.SPLIT_ALL)
produces the list containing:
{ "8", "-", "12", ",", "15", ",", "18" }
The OROMatcher split method does not follow this behavior. The following list would be produced by OROMatcher:
{ "8", "12", "15", "18" }
To obtain the Perl behavior, use
Perl5Util.split(java.util.Collection, java.lang.String, java.lang.String, int)
.
results
- A Collection to which the split results are appended.
After the method returns, it contains the substrings of the input
that occur between the regular expression delimiter occurences.
The input will not be split into any more substrings than the
specified limit
. A way of thinking of this is that
only the first limit - 1
matches of the delimiting
regular expression will be used to split the input.matcher
- The regular expression matcher to execute the split.pattern
- The regular expression to use as a split delimiter.input
- The String
to split.limit
- The limit on the number of resulting split elements.
Values <= 0 produce the same behavior as using the
SPLIT_ALL constant which causes the limit to be
ignored and splits to be performed on all occurrences of
the pattern. You should use the SPLIT_ALL constant
to achieve this behavior instead of relying on the default
behavior associated with non-positive limit values.public static void split(java.util.Collection results, PatternMatcher matcher, Pattern pattern, java.lang.String input)
String
instance and stores results as a
Collection
of all its substrings using a regular expression
as the delimiter.
This method is inspired by the Perl split() function and behaves
identically to it when used in conjunction with the Perl5Matcher and
Perl5Pattern classes except for the following difference:
split(list, "/([,-])/", "8-12,15,18")
produces the list containing:
{ "8", "-", "12", ",", "15", ",", "18" }
The OROMatcher split method does not follow this behavior. The following list would be produced by OROMatcher:
{ "8", "12", "15", "18" }
To obtain the Perl behavior, use
Perl5Util.split(java.util.Collection, java.lang.String, java.lang.String, int)
.
This method is identical to calling:
split(matcher, pattern, input, Util.SPLIT_ALL);
results
- A Collection
to which all the substrings of
the input that occur between the regular expression delimiter
occurences are appended.matcher
- The regular expression matcher to execute the split.pattern
- The regular expression to use as a split delimiter.input
- The String
to split.public static java.util.Vector split(PatternMatcher matcher, Pattern pattern, java.lang.String input, int limit)
split(Collection, PatternMatcher, Pattern, String, int)
instead.
String
instance into strings contained in a
Vector
of size not greater than a specified limit. The
string is split with a regular expression as the delimiter.
The limit parameter essentially says to split the
string only on at most the first limit - 1 number of pattern
occurences.
This method is inspired by the Perl split() function and behaves identically to it when used in conjunction with the Perl5Matcher and Perl5Pattern classes except for the following difference:
In Perl, if the split expression contains parentheses, the split() method creates additional list elements from each of the matching subgroups in the pattern. In other words:
split("/([,-])/", "8-12,15,18")
produces the Vector containing:
{ "8", "-", "12", ",", "15", ",", "18" }
The OROMatcher split method does not follow this behavior. The following Vector would be produced by OROMatcher:
{ "8", "12", "15", "18" }
To obtain the Perl behavior, use
Perl5Util.split(java.util.Collection, java.lang.String, java.lang.String, int)
.
matcher
- The regular expression matcher to execute the split.pattern
- The regular expression to use as a split delimiter.input
- The String
to split.limit
- The limit on the size of the returned Vector
.
Values <= 0 produce the same behavior as using the
SPLIT_ALL constant which causes the limit to be
ignored and splits to be performed on all occurrences of
the pattern. You should use the SPLIT_ALL constant
to achieve this behavior instead of relying on the default
behavior associated with non-positive limit values.Vector
containing the substrings of the input
that occur between the regular expression delimiter occurences.
The input will not be split into any more substrings than the
specified limit
. A way of thinking of this is that
only the first limit - 1
matches of the delimiting
regular expression will be used to split the input.public static java.util.Vector split(PatternMatcher matcher, Pattern pattern, java.lang.String input)
split(Collection, PatternMatcher, Pattern, String)
instead.
String
instance into a Vector
of all its substrings using a regular expression as the delimiter.
This method is inspired by the Perl split() function and behaves
identically to it when used in conjunction with the Perl5Matcher and
Perl5Pattern classes except for the following difference:
split("/([,-])/", "8-12,15,18")
produces the Vector containing:
{ "8", "-", "12", ",", "15", ",", "18" }
The OROMatcher split method does not follow this behavior. The following Vector would be produced by OROMatcher:
{ "8", "12", "15", "18" }
To obtain the Perl behavior, use
Perl5Util.split(java.util.Collection, java.lang.String, java.lang.String, int)
.
This method is identical to calling:
split(matcher, pattern, input, Util.SPLIT_ALL);
matcher
- The regular expression matcher to execute the split.pattern
- The regular expression to use as a split delimiter.input
- The String
to split.Vector
containing all the substrings of the input
that occur between the regular expression delimiter occurences.public static java.lang.String substitute(PatternMatcher matcher, Pattern pattern, Substitution sub, java.lang.String input, int numSubs)
matcher
- The regular expression matcher to execute the pattern
search.pattern
- The regular expression to search for and substitute
occurrences of.sub
- The Substitution used to substitute pattern occurences.input
- The String
on which to perform substitutions.numSubs
- The number of substitutions to perform. Only the
first numSubs patterns encountered are
substituted. If you want to substitute all occurences
set this parameter to SUBSTITUTE_ALL .public static java.lang.String substitute(PatternMatcher matcher, Pattern pattern, Substitution sub, java.lang.String input)
This method is identical to calling:
substitute(matcher, pattern, sub, input, 1);
matcher
- The regular expression matcher to execute the pattern
search.pattern
- The regular expression to search for and substitute
occurrences of.sub
- The Substitution used to substitute pattern occurences.input
- The String
on which to perform substitutions.public static int substitute(java.lang.StringBuffer result, PatternMatcher matcher, Pattern pattern, Substitution sub, java.lang.String input, int numSubs)
result
- The StringBuffer in which to store the result of the
substitutions. The buffer is only appended to.matcher
- The regular expression matcher to execute the pattern
search.pattern
- The regular expression to search for and substitute
occurrences of.sub
- The Substitution used to substitute pattern occurences.input
- The input on which to perform substitutions.numSubs
- The number of substitutions to perform. Only the
first numSubs patterns encountered are
substituted. If you want to substitute all occurences
set this parameter to SUBSTITUTE_ALL .public static int substitute(java.lang.StringBuffer result, PatternMatcher matcher, Pattern pattern, Substitution sub, PatternMatcherInput input, int numSubs)
result
- The StringBuffer in which to store the result of the
substitutions. The buffer is only appended to.matcher
- The regular expression matcher to execute the pattern
search.pattern
- The regular expression to search for and substitute
occurrences of.sub
- The Substitution used to substitute pattern occurences.input
- The input on which to perform substitutions.numSubs
- The number of substitutions to perform. Only the
first numSubs patterns encountered are
substituted. If you want to substitute all occurences
set this parameter to SUBSTITUTE_ALL .
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |