Share via


mdq.RegexReplace (Transact-SQL)

Within a specified input string, replaces strings that match a regular expression pattern with a specified replacement string. This function uses the regular expression functionality of the Regex.Replace method in the Microsoft .NET Framework. mdq.RegexReplace is in the mdq schema and is available only in the Master Data Services database.

Topic link iconTransact-SQL Syntax Conventions

Syntax

mdq.RegexReplace (input,pattern,replace,mask)

Arguments

  • input
    Is the input string for which to find a match. input is nvarchar(4000) with no default.

  • pattern
    Is the regular expression pattern to use for matching. pattern is nvarchar(4000) with no default.

  • replace
    Is the string to use to replace the matching tokens. replace is nvarchar(4000) with no default.

  • mask
    Is the RegexOptions mask that specifies the behavior of the regular expression. For more information, see mdq.RegexMask (Transact-SQL).

Return Code Values

nvarchar(4000)

Permissions

Requires membership in the public role.

Examples

The following example searches for all instances of the comma (,) in a string and replaces it with the pipe (|).

USE MDM_Sample;
GO

SELECT mdq.RegexReplace('A-B-C', '-', '|', 0);

See Also

Reference

Master Data Services Functions (Transact-SQL)

Concepts

Master Data Services

Other Resources

System.Text.RegularExpressions Namespace