LikeComparison 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LikeComparison --version 1.3.0
                    
NuGet\Install-Package LikeComparison -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LikeComparison" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LikeComparison" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="LikeComparison" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LikeComparison --version 1.3.0
                    
#r "nuget: LikeComparison, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LikeComparison@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LikeComparison&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=LikeComparison&version=1.3.0
                    
Install as a Cake Tool

NuGet Nuget Coverage Status

LikeComparison

LikeComparison is a library that allows you to compare a string expression to a pattern in an "SQL LIKE" expression.

It supports many LIKE operator syntax:

  • Visual Basic,
  • Transact-SQL (with ESCAPE),
  • PostgreSQL (both LIKE and ILIKE).

Main use:

  • Like method on strings
  • IsLike method on MSTest assertions
  • ShouldBeLike method on Shouldly assertions

Using Like method on strings

You can simply use extension method on String class:

using LikeComparison.VisualBasic;
string matchExpression = "abcdef";
string pattern = "a*";

bool isMatched = matchExpression.Like(pattern);

or

using LikeComparison.TransactSql;
string matchExpression = "abcdef";
string pattern = "a%";

// common use
bool isMatched = matchExpression.Like(pattern);

// or with escape character
bool isMatched = matchExpression.Like(pattern, escapeCharacter: "/");

or

using LikeComparison.PostgreSql;
string matchExpression = "abcdef";
string pattern = "a%";

// case-insensitive
bool isMatched = matchExpression.ILike(pattern);

// or case-sensitive
bool isMatched = matchExpression.Like(pattern);

Using IsLike method on MSTest assertions

You can simply use extension method on Assert class:

using LikeComparison.VisualBasic;
string matchExpression = "abcdef";
string pattern = "a*";

Assert.That.IsLike(matchExpression, pattern);

or

using LikeComparison.TransactSql;
string matchExpression = "abcdef";
string pattern = "a%";

// common use
Assert.That.IsLike(matchExpression, pattern);

// or with escape character
Assert.That.IsLike(matchExpression, pattern, escape: "/");

or

using LikeComparison.PostgreSql;
string matchExpression = "abcdef";
string pattern = "a%";

// case-insensitive
Assert.That.IsILike(matchExpression, pattern);

// or case-sensitive
Assert.That.IsLike(matchExpression, pattern);

Using ShouldBeLike method on Shouldly assertions

You can simply use extension method on String class:

using LikeComparison.VisualBasic;
string matchExpression = "abcdef";
string pattern = "a*";

matchExpression.ShouldBeLike(pattern);

or

using LikeComparison.TransactSql;
string matchExpression = "abcdef";
string pattern = "a%";

// common use
matchExpression.ShouldBeLike(pattern);

// or with escape character
matchExpression.ShouldBeLike(pattern, escape: "/");

or

using LikeComparison.PostgreSql;
string matchExpression = "abcdef";
string pattern = "a%";

// case-insensitive
matchExpression.ShouldBeILike(pattern);

// or case-sensitive
matchExpression.ShouldBeLike(pattern);

Supported syntax

Visual Basic

https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/like-operator

* ? [ ] ^ #

Transact-SQL

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql

% _ [ ] !

PostgreSQL

https://www.postgresql.org/docs/current/functions-matching.html

% _

Supported targets

.NET 7.0

  • Supported.
  • Additional target for LikeComparison.Tests.

.NET 6.0

  • Recommended.
  • Default target for LikeComparison.Tests and code coverage.

.NET Core 3.1

  • Supported.

.NET Framework 4.8

  • Experimental supported with C# 8.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on LikeComparison:

Package Downloads
LikeComparison.MSTest

LikeComparison is a library that allows you to compare a string expression to a pattern in an "SQL LIKE" expression. It supports many LIKE operator syntax: Visual Basic, Transact-SQL, PostgreSQL.

LikeComparison.Shouldly

LikeComparison is a library that allows you to compare a string expression to a pattern in an "SQL LIKE" expression. It supports many LIKE operator syntax: Visual Basic, Transact-SQL, PostgreSQL.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.2 396 6/24/2025
2.3.1 409 3/13/2025
2.3.0 392 11/20/2024
2.2.1 679 9/19/2024
2.2.0 1,283 1/23/2024
2.1.0 1,039 10/8/2023
2.0.1 493 7/26/2023
2.0.0 531 4/4/2023
1.3.3 1,611 3/16/2023
1.3.2 339 3/2/2023
1.3.1 599 11/27/2022
1.3.0 462 11/13/2022
1.2.1 849 6/21/2022
1.2.0 551 6/21/2022
1.1.1 1,798 3/9/2022
1.1.0 550 3/8/2022
1.0.13 599 2/12/2022
1.0.12 587 1/30/2022
1.0.11 560 1/16/2022
1.0.10 698 12/27/2021
1.0.9 407 12/15/2021
1.0.8 409 12/13/2021
1.0.7 433 12/8/2021
1.0.6 470 11/10/2021
1.0.5 464 11/3/2021
1.0.4 562 10/30/2021
1.0.3 584 10/23/2021
1.0.2 593 10/23/2021
1.0.1 462 10/19/2021
1.0.0 1,255 10/2/2021