Skip to content

Latest commit

 

History

History
74 lines (57 loc) · 3.27 KB

File metadata and controls

74 lines (57 loc) · 3.27 KB

NuGet Pre Release NuGet Downloads

SimpleStateMachine.StructuralSearch

StructuralSearch - An easy-to-use library for structural search and replace in text in any programming language.

Give a Star! ⭐

If you like or are using this project please give it a star. Thanks!

Why SimpleStateMachine?

Forget about regular expressions and *enjoy searching

  1. Describe search pattern🔎
// Just text and placeholders
var template = StructuralSearch.ParseFindTemplate("void $methodName$($params$)")
  1. Find it in any text📄
// All the matches are already here
var results = template.ParseString("void MyMethodName(int value1, double value2)"
  1. Enjoy the search results📑
// The found text part
parseResult.Match.Value // void MyMethodName(int value1, double value2)

// The exact coordinates of the match
parseResult.Match.Column // Start 1, End 45
parseResult.Match.Line // Start 1, End 1
parseResult.Match.Offset // Start 0, End 44
    
// Placeholders
parseResult.Placeholders // { "methodName" : "MyMethodName" }, { "params": "int value1, double value2" }
    
// The exact coordinates of each placeceholdder
parseResult.Placeholders[0].Column // Start 6, End 18
parseResult.Placeholders[0].Line // Start 1, End 1
parseResult.Placeholders[0].Offset // Start 5, End 17

Grammar

grammar = term EOF
term = '(' term ')' | '{' term '}' | '[' term ']' | term + | token
token = placeholder | string_literal | whitespaces | comment
placeholder = '$' identifier '$'
string_literal = <escaped string>
whitespace = [\n\r| '\n' | ' '] +
comment = <single or multiline comment>

Getting Started📂

Install from Nuget:

 Install-Package SimpleStateMachine.StructuralSearch

Documentation📄

Documentation here: wiki

FAQ❔

If you think you have found a bug, create a github issue.

But if you just have questions about how to use:

License📑

Copyright (c) SimpleStateMachine

Licensed under the MIT license.