ReplaceAll
Description
Replaces each substring of a string that matches the given regular expression with the given replacement. A new column is created for the results.
Use
- Argument:
- Select an argument. (String)
- Regex:
- Enter a regular expression to match with the argument's value.
- Replacement:
- Enter a replacement value for the argument values matching with the regular expression.
- Output field name:
- Enter an output field name.
Example
Replace Blank Spaces With an Underscore
A user wants to replace all blank spaces within a field with an underscore characters.
Users |
---|
Jeff Mesos |
Elaine Toffy |
Gretta Schmidt |
Fred Williams |
The user selects the ReplaceAll function and Users for the argument.
The regular expression to match a blank space is \s
The user enters an underscore character _ as the replacement.
ReplaceAll() returns |
---|
Jeff_Mesos |
Elaine_Toffy |
Gretta_Schmidt |
Fred_Williams |
Replace a Word With a Different Word
A user wants to replace all text in a field that contains the word "schokolade” with the word “chocolate”.
Flavor Choice |
---|
schokolade |
strawberry |
schokolade |
blueberry |
The user selects the ReplaceAll function and Flavor Choice for the argument.
The regular expression to match "schokolade" is (schokolade)
The user enters chocolate as the replacement.
ReplaceAll() returns |
---|
chocolate |
strawberry |
chocolate |
blueberry |
Replacements With Grouping From the Input String
The user wants different parts of a string in separate fields.
Example Text |
---|
https://s3.amazonaws.com/blab-impact-published-production/jF0pqZokwXThdnhZPOD3SMNLCiSgQodn" target="_blank" title="Download this document" class="btn btn-default btn-lg btn-block btn-icon"><i class="small material-icons">file_download</i>Aggregated Scoring Methodology Summary 2020</a> |
The user selects the ReplaceAll function and Example Text for the argument.
The regular expression matches patterns for different groupings of text within the string value.
(https://s3/.+)?(" target)(.*\s)+?(.*)?(</i>)(.+)(\s)?(</a>)
The user can now enter a regular expression into the replacement field to call the matching group.
Enter the regular expression $1
ReplaceAll() returns |
---|
https://s3.amazonaws.com/blab-impact-published-production/jF0pqZokwXThdnhZPOD3SMNLCiSgQodn |
Enter the regular expression $6
ReplaceAll() returns |
---|
Aggregated Scoring Methodology Summary 2020 |
Hero Platform_ Example
An example of this function can be found in Hero Platform_'s library of examples.
Download the example titled "function_ReplaceAll" to see an example of this function.