Package org.cdlib.mrt.utility
Class RegexUtil
java.lang.Object
org.cdlib.mrt.utility.RegexUtil
This class contains a set of utilities that were built to emulate some of the nicer Perl conversion functions. Note that the Regex handling uses RegexCache for caching the compiled form of the regular expression Created on January 29, 2004, 12:22 PM
- Author:
- David Loy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]
listMatches
(String inStr, String patternS) Return list of multiple matches from single pattern matchstatic String[]
listPattern
(String inStr, String patternS) Return the subpattern matches for a single patternstatic String
replacePatternString
(String inStr, String patternS, String fromValue, String toValue) Use from and to values to do a replacement within strings matching the given patternstatic String
replaceString
(String in, String from, String to) replace a substring value with another substring valuestatic String
substitute
(String inStr, String patternS, String[] array) Based on Perl substitute - constructs a response string using the paranthetical subpatternsstatic String
substitute
(String inStr, String patternS, String[] array, int flags) Based on Perl substitute - constructs a response string using the paranthetical subpatterns
-
Constructor Details
-
RegexUtil
public RegexUtil()
-
-
Method Details
-
replaceString
replace a substring value with another substring value- Parameters:
in
- - string to have value replacefrom
- - current substring value in 'in'to
- - replacement value for 'from'- Returns:
- - new string with replaced substrings
-
replacePatternString
public static String replacePatternString(String inStr, String patternS, String fromValue, String toValue) Use from and to values to do a replacement within strings matching the given pattern- Parameters:
inStr
- string to matchpatternS
- pattern to be matchedfromValue
- string to be matched for replacementtoValue
- string used for replacement- Returns:
- string containing replacements
-
listMatches
Return list of multiple matches from single pattern match- Parameters:
inStr
- string to matchpatternS
- pattern to be matched- Returns:
- list of strings containing the subpattern match
-
substitute
Based on Perl substitute - constructs a response string using the paranthetical subpatterns- Parameters:
inStr
- string to matchpatternS
- pattern to be matchesarray
- contains a set of String values that will be sequentially used to construct the output. The array element may contain a reference to the match substring - so "$1" corresponds to the first matched subpattern- Returns:
- list of strings containing the subpattern match
-
substitute
Based on Perl substitute - constructs a response string using the paranthetical subpatterns- Parameters:
inStr
- string to matchpatternS
- pattern to be matchesarray
- contains a set of String values that will be sequentially used to construct the output. The array element may contain a reference to the match substring - so "$1" corresponds to the first matched subpattern- Returns:
- list of strings containing the subpattern match
-
listPattern
Return the subpattern matches for a single pattern- Parameters:
inStr
- string to matchpatternS
- pattern to be matched- Returns:
- list of strings containing the subpattern match
-