Skip to main content
Version: 24.3.x

Categories: String, Regular Expressions

REGEXP_REPLACE

Finds strings that match the given regular expression and replaces the strings with the given string.

Syntax

REGEXP_REPLACE(input string, regex string, replacement_string string) → string

  • input: The expression to search for a matching string.
  • regex: The Perl-compatible regular expression (PCRE) to match against.
  • replacement_string: The string with which to replace the matching string.

Examples

REGEXP_REPLACE example
SELECT REGEXP_REPLACE('8AM-4PM', '\Q-\E', ' to ')
-- 8AM to 4PM
REGEXP_REPLACE example
SELECT REGEXP_REPLACE(Address, '\QST\E', 'STREET') 
FROM Samples."samples.dremio.com"."SF_incidents2016.json"
LIMIT 3
-- Raw data
-- 800 Block of BRYANT ST
-- 800 Block of BRYANT ST
-- KEITH ST / SHAFTER AV

-- Returned data
-- 800 Block of BRYANT STREET
-- 800 Block of BRYANT STREET
-- KEITH STREET / SHAFTER AV