REGEXREPLACE
finds appearances of a regex within a block of text and replaces it.
Function category: Text​
REGEXREPLACE(arg1, arg2, arg3)
Arguments | Description |
arg1 | String to be searched. |
arg2 | regex pattern to be searched in the string. Any match replaced with |
arg3 | String that replaces any instances of |
Let's say we're given a response with that following vehicle information.
{"data":{"mechanic_reports":{"vehicle_1":{"description":"The car was functional but was in a bad condition."}}}}
If we know that the description
attribute is going to have a standard structure and used standardized terminology, we can do a search and replace using REGEXREPLACE. In this example, we search for "bad"
and replace it with "imperfect"
.
# Find and replace a stringREGEXREPLACE("The car was functional but was in a bad condition.", "a bad", "an imperfect")​# Returns "The car was still functional but was in an imperfect condition."