1. Download DLL assemblies (supported regular methods written in C #), Baidu network disk Download:
1.1 If you want to use it, you can download it directly MSSQLRegexExtend.dll
Https://pan.baidu.com/s/1qX8eHa8
1.2 Regular assembly corresponding solution MSSQLRegexExtend.sln, packaged
https://pan.baidu.com/s/1qXZja9m
2.SQL Server Database Registration assembly
3. Set enable CLR support
EXEC sp_configure ' clr enabled ', 1 RECONFIGURE
4. Creating scalar functions that support regular matching
--drop FUNCTION [dbo]. [Regexmatch] CREATE FUNCTION [dbo]. [Regexmatch] (@Regex [nvarchar] (max), @Input [nvarchar] (max)) RETURNS [nvarchar] (max) with EXECUTE as CALLER as EXTERNAL NAME [assemblyregex].[ Mssqlregexextend.regexextend]. [Match]
5. Creating scalar functions that support regular substitution
--drop FUNCTION [dbo]. [Regexreplace] CREATE FUNCTION [dbo]. [Regexreplace] (@Regex [nvarchar] (max), @Input [nvarchar] (max), @Replace [nvarchar] (max ) RETURNS [nvarchar] (max) with EXECUTE as CALLER as EXTERNAL NAME [assemblyregex].[ Mssqlregexextend.regexextend]. [Replace]
6. Creating scalar functions that support regular checks
--drop FUNCTION [dbo]. [Regexismatch] CREATE FUNCTION [dbo]. [Regexismatch] (@Regex [nvarchar] (max), @Input [nvarchar] (max)) RETURNS [Bit] with EXECUTE as CALLER as EXTERNAL NAME [assemblyregex].[ Mssqlregexextend.regexextend]. [IsMatch]
Simple regular in the attached section:
/*. Match any character except a newline \w match a letter or number or an underscore or a Chinese character \s match any white space character \d match a number \b match the beginning or end of the word ^ match string to the beginning of the match string end *//** repeat 0 or more times +
Repeat one or more times? Repeat 0 times or once {n} repeats n times {n,} repeats n times or more {n,m} repeats n to M times \w matches any character that is not a letter, number, underscore, kanji \s matches any character that is not a white space symbol \d Matches any non-numeric character \b matches a position other than the beginning or end of a word [^x] matches any character except for X [^aeiou] matches any character except aeiou the IP address matches: ((2[0-4]\d|25[0-5]|[ 01]?\d\d?) \.) {3} (2[0-4]\d|25[0-5]| [01]?\d\d?] (\d{1,3}\.) {3}\d{1,3} is a simple IP-address matching expression. Expression Order Analysis: \d{1,3} matches numbers from 1 to 3 digits, (\d{1,3}\.) {3} matches three digits plus an English period (this whole is the group) repeats 3 times, and finally adds a one to three digits (\d{1,3}). */
SQL Server registers regular expression functions (CLR functions) with external assemblies