ReplaceStrRegex
ReplaceStrRegex( value, pattern, replace, [ first_only ] )
ReplaceStrRegex( value, pattern, replace, [ first_only ] )
ReplaceStrRegex( value, pattern, replace, [ first_only ] )
ReplaceStrRegex( value, pattern, replace, [ first_only ] )
replace_str_regex( value, pattern, replace, [ first_only ] )
ReplaceStrRegex( value, pattern, replace, [ first_only ] )
Description
The ReplaceStrRegex
function returns a string which has either the first or
all occurrences of the pattern
replaced with the replace
string. The
pattern conforms to Java regular expression syntax.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
The source String to perform replacements within. |
|
|
The Java regular expression to match against the |
|
|
The new String that replaces the sub-string found by |
|
|
Optional - When Since Go does not have function overloading or optional arguments, you
must use the function |
Returns
A String which has either the first or all occurrences of the
pattern
replaced with the replace
string.
Examples
The following query executes an array of independent ReplaceStrRegex
operations and returns the results in an Array. The result array
position matches the execution array position.
The individual operations are:
-
The string "One Fish Two Fish" is processed, replacing the pattern "Two" with the string "Blue". The result string "One Fish Blue Fish" is placed in the top position of the result array.
-
The string "One Fisk Two FisT" is processed, replacing every string matching the pattern "Fis." with the string "Fish". The result string "One Fish Two Fish" is placed in the second position of the result array.
-
The same string "One Fisk Two FisT" is processed, but because it has the
first_only
flag set totrue
, only the first string matching the pattern "Fis." is replaced. The result string "One Fish Two FisT" is placed in the third position of the result array.
Arr(StringV(One Fish Blue Fish), StringV(One Fish Two Fish), StringV(One Fish Two FisT))
[One Fish Blue Fish One Fish Two Fish One Fish Two FisT]
["One Fish Blue Fish", "One Fish Two Fish", "One Fish Two FisT"]
[ 'One Fish Blue Fish', 'One Fish Two Fish', 'One Fish Two FisT' ]
["One Fish Blue Fish", "One Fish Two Fish", "One Fish Two FisT"]
[ 'One Fish Blue Fish', 'One Fish Two Fish', 'One Fish Two FisT' ]
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!