Project Description

Regular expression pattern syntax is addictive because it is so compact and concise, but this also makes them cryptic and difficult to read and maintain.  Most developers have only occasional exposure to regular expressions, making their syntax and features difficult to recall.    

The Regular Expression Pattern Builder allows you to use code to generate patterns.  The builder API and intellisense/type-ahead allow you access to all regular expression features, without requiring expression syntax to be committed to memory.  The result is that regular expressions become more approachable/usable, and maintenance becomes easier.    

The Builder does not attempt to abstract the concepts of regular expressions, but simply makes them more accessible.  Because of this, you should be familiar regular expression concepts prior to using this library. 


Match Phone Number

var builder = new RegexPatternBuilder();
Match(CharacterClass.Digit, 3).Match('-').Match(CharacterClass.Digit, 4);

Regex.IsMatch("123-4567", builder.ToString());


Match Year

var builder = new RegexPatternBuilder();
Alternate(l => l.Match("19"), r => r.Match("20"))
.Match(CharacterClass.Digit, 2)


First Name/Last Name

var builder = new RegexPatternBuilder();
builder.Group("Firstname", g => g.Match('A', 'Z').Match(CharacterClass.Word, 0, Qualifier.OrMore))
.Group("Lastname", g => g.Match('A', 'Z').Match(CharacterClass.Word, 0, Qualifier.OrMore));


Last edited Apr 4, 2016 at 2:48 AM by wimpleshapers, version 9