High-performance regex engine supporting intersection and complement operations
$ dotnet add package Resharpweb application and examples: https://ieviev.github.io/resharp-webapp/
_ - any character (same as [\s\S] or [\w\W])~ - complement, ex. "does not contain 1" => ~(_*1_*)& - intersection, ex. "contains cat and dog and 5-15 chars long" => _*cat_*&_*dog_*&_{5,15}#r "nuget: resharp"
Resharp.Regex("hello.*world").Matches("hello world!")
#r "nuget: resharp"
open System
open System.IO
// building the engine is the most expensive part, reuse this
let engine =
Resharp.Regex("hello.*world", Resharp.ResharpOptions.HighThroughputDefaults)
let chars = System.Text.Encoding.UTF8.GetChars(File.ReadAllBytes("my-file.txt"))
let result =
use spans = engine.MatchSlices(chars)
for span in spans do
let content = span.GetText(chars) // optionally get content
printfn $"found {content} at {span.Index}..{span.Length}"