Skip to content

lumpn/unity-regex

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

regex-composer

Compose regular expressions using code

Usage

// +1 555-555-5555
// country code and separators optional

var digit = Pattern.Digit;
var dash = Pattern.Dash;
var space = Pattern.Space;
var separator = new Optional(dash | space);

var optionalPlus = Pattern.Plus.Optional();
var someDigits = new OneOrMore(digit);

var countryCode = new Optional(optionalPlus + someDigits);
var phone = countryCode + separator + digit * 3 + separator + digit * 3 + separator + digit * 4;

var regex = phone.ToRegex();

Assert.IsTrue(regex.IsMatch("+1 555-555-5555"));

About

Compose regular expressions using code

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages