Skip to main content
Workday User Guide
Last Updated: 2023-06-23
REGEX_REPLACE

REGEX_REPLACE

Description

REGEX_REPLACE
is a row function that evaluates a
TEXT
value against a regular expression to determine if there is a match, and replaces matched strings with the specified replacement value.

Syntax

REGEX_REPLACE
(
string_expression
,"
regex_match_pattern
","
regex_replace_pattern
")

Return Value

Returns the
regex_replace_pattern
as a
TEXT
value when
regex_match_pattern
produces a match. If there is no match, returns the value of
string_expression
as a
TEXT
.

Input Parameters

string_expression
Required. The name of a field or expression of type
TEXT
(or a literal string).
regex_match_pattern
Required. A string literal or regular expression pattern based on the regular expression pattern matching syntax of the Java programming language. You can use capturing groups to create backreferences that can be used in the
regex_replace_pattern
. You might want to use a string literal to make a case-sensitive match. For example, when you enter
jane
as the match value, the function matches
jane
but not
Jane
. The function matches all occurrences of a string literal in the string expression.
regex_replace_pattern
Required. A string literal or regular expression pattern based on the regular expression pattern matching syntax of the Java programming language. You can refer to backreferences from the
regex_match_pattern
using the syntax
$
n
(where
n
is the group number).

Regular Expression Constructs

See the Regular Expression Reference for information on the constructs used for defining a regular expression matching pattern.

Examples

Match the values in a
phone_number
field where phone number values are formatted as
xxx.xxx.xxxx
and replace them with phone number values formatted as
(xxx) xxx-xxxx
:
REGEX_REPLACE([phone_number], "([0-9]{3})\.([[0-9]]{3})\.([[0-9]]{4})", "\($1\) $2-$3")
Match the values in a
name
field where name values are formatted as
firstname lastname
and replace them with name values formatted as
lastname, firstname
:
REGEX_REPLACE([name], "(.*) (.*)", "$2, $1")
Match the string literal
mrs
in a
title
field and replace it with the string literal
Mrs
.
REGEX_REPLACE([title], "mrs", "Mrs")