String replaceFirst(String
<input>, String
<regex>, String
<replacement>)
-
<input> is the string to search and replace in
-
<regex> is the regular expression to which this string is to be matched
-
<replacement> is the string to be substituted for the first match
|
Replaces the first substring of the text string that matches the given regular expression with the given replacement. A null reference passed to this method is a no-op and returns null .
|
-
#regex.replaceFirst('upper case', '()(
+)([a-z])', '$1_$3')
-
#regex.replaceFirst('upper case AND lower case',
'()( +)([a-z])', '$1_$3')
|
-
upper_case
-
upper_case AND lower case
|
String replaceAll(String
<input>, String
<regex1>, String
<replacement1>, …, String
<regexN>, String
<replacementN>)
-
<input> is the string to search and replace in
-
<regex1> is the regular expression to which this string is to be matched
-
<replacement1> is the string to be substituted for each match
-
<regex[2…N]> is an optional additional regular expression to which this string is to be matched
-
<replacement[2…N]> is an optional additional string to be substituted for each match. If replacement is missing, the corresponding regex string won’t be altered.
|
The first pair of find-replace arguments are mandatory and the rest are optional.
|
|
Replaces each substring of the text string that matches the given regular expression with the given replacement. You can use this for 1 or more find and replace options. The first pair of find-replace arguments are mandatory and the rest are optional.
|
-
#regex.replaceAll('upper case AND lower case',
'()( +)([a-z])', '$1_$3')
-
#regex.replaceAll('numeric data to be replaced with
textual data [1, 2]', 'to be', '', '1', 'one', '2',
'two')
|
-
upper_case AND lower_case
-
numeric data replaced with textual data [one,
two]
|
boolean matches(String <input>,
String <regex>)
|
Checks if the entire input string matches the regex pattern. If a null is passed as input, it returns false .
|
#regex.matches('upper case', '()(
+)([a-z])')
|
|
Array findAllMatches(String
<input>, String
<regex>)
|
Find all matching substrings in the input string matching the regex pattern.
|
#regex.findAllMatches('upper case AND lower case',
'()( +)([a-z])')
|
["upper case", "lower case"]
|