RegexGenerator - A language-independent regex pattern generator written in C# and .NET Standard 1.0.
Address: 19inR1nynLZ93Q72v1cqoVoDesN7xKbDu9
Address: 0x1226378d71DB5bf16DF0A2fe52C3c7917739da0A
This project is intended to help developers to generate complex regex pattern syntax by combining basic pattern blocks.
- .NET
- ECMAScript (Typically known implementation is JavaScript, and the superset TypeScript)
- (Others need your contributions!)
By default, you will generate regex pattern syntax for .NET.
using System.Text.RegularExpressions;
using WilliamWsy.RegexGenerator;
// ...
var text = "2017";
var regexGenerator = new RegexGenerator(/*RegexLanguage.DotNet*/)
.AddPositiveLookbehindAssertion(@"\b20")
.Add(@"\d", min: 2, max: 2)
.Add(@"\b");
// Check the generated regex pattern syntax.
var generatedPattern = regexGenerator.ToString(); // = @"(?<=\b20)\d{2}\b"
// Only for RegexLanguage.DotNet: Create a native .NET Regex object to test the pattern!
Regex generatedRegex = regexGenerator.Create();
var match = generatedRegex.Match(text);
// ...
And ECMAScript,
using System.Text.RegularExpressions;
using WilliamWsy.RegexGenerator;
// ...
var text = "2017";
var regexGenerator = new RegexGenerator(RegexLanguage.ECMAScript)
.AddPositiveLookbehindAssertion(@"\b20")
.Add(@"\d", min: 2, max: 2)
.Add(@"\b");
// Check the generated regex pattern syntax.
var generatedPattern = regexGenerator.ToString(); // = @"/(?<=\b20)\d{2}\b/"
// ...
Create issues / pull requests are all welcome. Please create test cases as appropriate in the mean time you add a new class / function.
MIT License; Always welcome business / enterprise to register their name here when using this project!