Shrike 3.1.0

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

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

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.
  • net5.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Shrike:

Package Downloads
Shrike.Harmony

An additional library for Shrike, for usage with the Harmony method patching library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.0 232 3/9/2024
3.0.0 378 12/20/2023
2.1.0 293 6/18/2023
2.0.0 172 5/9/2023
1.1.0 295 1/9/2023
1.0.1 485 1/8/2023
1.0.0 641 12/18/2022