RegexReplace
Replaces a string that matches a regular expression pattern with a specified replacement string
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT SQLHTTP.net.RegexReplace ( @Text, @RegexPattern, @Replacement )
Name | Type | Description |
---|---|---|
@Text | nvarchar(MAX) |
String expression containing substrings and delimiters. |
@RegexPattern | nvarchar(4000) |
String expression containing a regex expression. See Regular Expression Language – Quick Reference for more information. Even though this parameter is required, a NULL value indicates that no regex expression is to be used. |
@Replacement | nvarchar(4000) | A replacement string for each RegexPattern occurrence found. |
nvarchar(MAX)
Strip non-AlphaNumeric characters from a string
1 2 3 |
SELECT SQLHTTP.net.RegexReplace('1!q2@w3#W', '[^a-zA-Z0-9]', '') |
1 2 3 4 5 |
-------- 1q2w3W |