Shrike.Harmony 3.1.1

dotnet add package Shrike.Harmony --version 3.1.1
NuGet\Install-Package Shrike.Harmony -Version 3.1.1
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="Shrike.Harmony" Version="3.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Shrike.Harmony --version 3.1.1
#r "nuget: Shrike.Harmony, 3.1.1"
#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.
// Install Shrike.Harmony as a Cake Addin
#addin nuget:?package=Shrike.Harmony&version=3.1.1

// Install Shrike.Harmony as a Cake Tool
#tool nuget:?package=Shrike.Harmony&version=3.1.1

Shrike

A generic sequence matching library, with an additional Harmony-IL-tailored sublibrary.

Installation

Reference the Nanoray.Shrike NuGet package in your project.

The NuGet package is compatible with .NET 5+, with some small API changes when using with .NET 7+.

Usage examples

Finding a sequence of uppercase-only, then lowercase-only, then uppercase-only strings in a row, then removing that sequence

ElementMatch<string> uppercase = new("uppercase", e => e.ToUpper() == e);
ElementMatch<string> lowercase = new("lowercase", e => e.ToLower() == e);

IEnumerable<string> newElements = new SequenceBlockMatcher<string>(
    "lorem ipsum dolor sit amet",
    "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG",
    "oak is strong and also gives shade",
    "CATS AND DOGS EACH HATE THE OTHER",
    "the pipe began to rust while new"
)
    .Find(uppercase, lowercase, uppercase)
    .Remove()
    .AllElements();

Finding a specific element, then replacing the element two places after it with two other elements

IEnumerable<string> newElements = new SequenceBlockMatcher<string>(
    "a", "b", "c", "d", "e", "f"
)
    .Find(new ElementMatch<string>("c"))
    .PointerMatcher(SequenceMatcherRelativeElement.First)
    .Advance(2)
    .Replace("1", "2")
    .AllElements();

Finding a sequence of 1-, 2-, 3-, 4-, 5-long strings, anchoring the 3-long element, then removing it and its neighbors

IEnumerable<string> newElements = new SequenceBlockMatcher<string>(
    "a", "bb", "ccc", "dd", "e", "ff", "ggg", "hhhh", "iiiii", "jjjj", "kkk", "ll", "m", "nn", "ooo", "pp", "q"
).AsGuidAnchorable()
    .Find(
        new ElementMatch<string>("1-long", e => e.Length == 1),
        new ElementMatch<string>("2-long", e => e.Length == 2),
        new ElementMatch<string>("3-long", e => e.Length == 3).WithAutoAnchor(out Guid anchor),
        new ElementMatch<string>("4-long", e => e.Length == 4),
        new ElementMatch<string>("5-long", e => e.Length == 5)
    )
    .PointerMatcher(anchor)
    .Encompass(SequenceMatcherEncompassDirection.Both, 1)
    .Remove()
    .AllElements();

See also

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.1 84 4/14/2024
3.1.0 74 4/14/2024
3.0.0 330 12/20/2023
2.0.2 164 11/24/2023
2.0.1 113 11/23/2023
2.0.0 157 5/9/2023
1.1.0 280 1/9/2023
1.0.1 261 1/8/2023
1.0.0 249 12/18/2022