Giter Club home page Giter Club logo

sql-server-regex's Introduction

SQL Server Regex

SQL Regex Logo

SQL-Server-Regex gives you the power to run regular expressions inside SQL Server queries. It works by using SQL CLR functions to call the C# System.Text.RegularExpressions library.

Examples

Match

The RegexMatch() scalar function lets you call a regular expression against a string, and returns the first result if there is a match.

Match SSMS example

Matches

The RegexMatches() table-valued function lets you call a regular expression against a string, and returns all matches.

Matches SSMS example

Group Match

The RegexGroupMatch() scalar function lets you call a regular expression with named groups against a string, and returns the group name you specify.

Group Match SSMS example

Replace

The RegexReplace() scalar function lets you call a regular expression to find-and-replace inside a string. You can also match parts of a string and re-arrange them using references.

Replace SSMS example

Split

The RegexSplit() table-valued function lets you call a regular expression against a string to split it into pieces, and returns the pieces.

Split SSMS example

Installation

You can install sql-server-regex on most versions of SQL Server. This works the same for virtual machines or cloud VMs.

You can also install sql-server-regex onto AWS RDS.

Note: for SQL Server 2005, 2008, and 2008R2, if you can't install the DLL directly, you may you need to compile the assembly yourself using .NET 2.0 and an old version of Visual Studio.

Testing

This work has been tested, both for functionality and performance.

Resources

sql-server-regex's People

Contributors

devnambi avatar maxpowis avatar witheej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sql-server-regex's Issues

Missing 2019 DLL version

Can someone please compile version for MSSQL 2019? Last compiled DLL is 2016.

Also 2019 version requires adding DLL hash to trusted DLLs, which should me mentioned in description.

Example for 2016 DLL version (hash is SHA2-512)

EXEC sp_add_trusted_assembly 0x52A8DC6C31B95961455746731FEC5DC4E8BF7F8791A6854473BB4F9A9577AA2BC4376213EC4AD9C3ADB0A0A55CEACCEBB9A01D7AC5CCBACA054B0F14EF4212D1 

Thanks

add registration to all database

I tested your project, and had a little trouble with connecting from the worked database.
Please add script to registration
DECLARE @Sql NVARCHAR(MAX) = N'';

SELECT @Sql += CHAR(13) + CHAR(10)

  • 'USE ' + QUOTENAME(name) + ';

IF OBJECT_ID(''dbo.RegexSplit'', ''FN'') IS NOT NULL
DROP FUNCTION dbo.RegexSplit;

IF OBJECT_ID(''dbo.RegexSplit'', ''SN'') IS NOT NULL
DROP SYNONYM dbo.RegexSplit

CREATE SYNONYM dbo.RegexSplit FOR master.dbo.RegexSplit;'
FROM sys.databases WHERE name <> 'master';

PRINT @Sql;

EXEC sp_executesql @Sql;

replacement could be empty string

Good Job!
1,Usually Replace function need replace something to empty,please fix .
2,download for 2008 ,2005 dll cannot execute 1load-assembly.sql,because the sqlserver didn't support .net 4.0.
TKS.

CREATE ASSEMBLY error

I get the following issue when running load-assembly.sql:

CREATE ASSEMBLY for assembly 'RegexAssembly' failed because assembly 'RegexAssembly' is malformed or not a pure .NET assembly.
Unverifiable PE Header/native stub.

Case sensitive

Thanks for your code , it helps me a lot .
Since I'm not familiar with C# , I don't konw how to set the case sensitive off .
Could you please help me ?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.