paviad / sql-like-to-regex

A small library that converts SQL LIKE expressions to regular expressions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sql Like to Regex

This library converts SQL LIKE expressions to regular expressions.

It is based on a C# translation of the Java code from Damon Sutherland at https://codereview.stackexchange.com/a/207486/274158

Obtaining from Nuget.Org

dotnet add package SqlLikeToRegex

Usage

Call the static method SqlLikeTranspiler.ToRegEx to convert an SQL LIKE expression to a regular expression. The function returns a string (not a Regex object).

Example

var result = SqlLikeTranspiler.ToRegEx("%abc[%]%")

The expected result is ^.*abc[%].*$

About

A small library that converts SQL LIKE expressions to regular expressions

License:MIT License


Languages

Language:C# 100.0%