Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

REGEXREPLACE

Dan Gorman edited this page Nov 29, 2018 · 2 revisions

The REGEXREPLACE Function

Function Group: Text

REGEXREPLACE finds appearances of a regex within a block of text and replaces it.

Syntax

REGEXREPLACE(arg1, arg2, arg3)

  • arg1 is a string to be searched
  • arg2 is the regex pattern to be searched for - any instance matched will be replaced with arg3
  • arg3 is a string that will replace any found instances of arg2

Uses

Let's say we're given a response with some vehicle information that looks like this:

{  
   "data":{  
      "mechanic_reports":{  
         "vehicle_1":{  
            "description":"The car was still functional, but had bad axels, and was in 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 for, let's say, "bad":

REGEXREPLACE("The car was still functional, but had a bad axels, and was in bad condition.", "ba.", "imperfect")

"The car was still functional, but had imperfect axels, and was in imperfect condition."

Clone this wiki locally