forked from DevNambi/sql-server-regex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scalar-functions.sql
36 lines (28 loc) · 898 Bytes
/
scalar-functions.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
if OBJECT_ID('dbo.RegexMatch') is not null
begin
exec ('drop function dbo.RegexMatch');
end
go
if OBJECT_ID('dbo.RegexGroupMatch') is not null
begin
exec ('drop function dbo.RegexGroupMatch');
end
go
if OBJECT_ID('dbo.RegexReplace') is not null
begin
exec ('drop function dbo.RegexReplace');
end
go
-- see https://msdn.microsoft.com/en-us/library/ms186755.aspx for details
CREATE FUNCTION dbo.RegexMatch (@input nvarchar(max), @pattern nvarchar(max))
RETURNS nvarchar(max)
AS EXTERNAL NAME [RegexAssembly].[UDF].[Match]
go
CREATE FUNCTION dbo.RegexGroupMatch (@input nvarchar(max), @pattern nvarchar(max), @group nvarchar(max))
RETURNS nvarchar(max)
AS EXTERNAL NAME [RegexAssembly].[UDF].[GroupMatch]
go
CREATE FUNCTION dbo.RegexReplace (@input nvarchar(max), @pattern nvarchar(max), @replacement nvarchar(max))
RETURNS nvarchar(max)
AS EXTERNAL NAME [RegexAssembly].[UDF].[Replace]
go