StructuralSearch - An easy-to-use library for structural search and replace in text in any programming language.
If you like or are using this project please give it a star. Thanks!
Forget about regular expressions and *enjoy searching
- Describe search pattern🔎
// Just text and placeholdersvartemplate=StructuralSearch.ParseFindTemplate("void $methodName$($params$)")- Find it in any text📄
// All the matches are already herevarresults=template.ParseString("void MyMethodName(int value1, double value2)"- Enjoy the search results📑
// The found text partparseResult.Match.Value// void MyMethodName(int value1, double value2)// The exact coordinates of the matchparseResult.Match.Column // Start 1, End 45
parseResult.Match.Line // Start 1, End 1
parseResult.Match.Offset // Start 0, End 44// PlaceholdersparseResult.Placeholders // { "methodName" : "MyMethodName" }, { "params": "int value1, double value2" }// The exact coordinates of each placeceholdderparseResult.Placeholders[0].Column // Start 6, End 18
parseResult.Placeholders[0].Line // Start 1, End 1
parseResult.Placeholders[0].Offset// Start 5, End 17logic_expr=binary_operation|not_operation|string_comparison_operation|type_check_operation|match_operation|in_operation|'('logic_expr')'binary_operation=logic_expr ('And'|'Or'|'NAND'|'NOR'|'XOR'|'XNOR') logic_exprstring_comparison_operation=string_expr ('Equals'|'Contains'|'StartsWith'|'EndsWith') string_exprnot_operation='Not'logic_exprtype_check_operation=string_expr'Is' ('Var'|'Int'|'Double'|'DateTime'|'Guid')
match_operation=string_expr'Match''"' <regex> '"'in_operation=string_expr'In' [ '(' ] string_expr { ','string_expr } [ ')' ]
string_expr=grouped_string|property_access|atomic_tokengrouped_string='('string_expr')'|'{'string_expr'}'|'['string_expr']'property_access=placeholder'.' (
'Length'|complex_property|input_property [ chainable_string ]
)
|placeholder [ chainable_string ]
chainable_string= { '.' ('Trim'|'TrimEnd'|'TrimStart'|'ToUpper'|'ToLower') }
input_property='Input.'identifiercomplex_property= ('Offset'|'Line'|'Column') '.' ('Start'|'End')
atomic_token=placeholder|string_literal|whitespace|commentplaceholder='$'identifier'$'string_literal= <escapedstring>
whitespace= (''|'\n'|'\r')+comment= <singleormultilinecomment>Install from Nuget:
Install-Package SimpleStateMachine.StructuralSearchDocumentation here: wiki
If you think you have found a bug, create a github issue.
But if you just have questions about how to use:
Copyright (c) SimpleStateMachine
Licensed under the MIT license.