License Public Domain
Lines 12
Keywords
C# (7) .Net (8) RegEx (1) Regular Expression (1) VB.Net (5)
Included in this Library
Permissions
Group Owner: .Net
Viewable by Everyone
Editable by Spencer Ruport
Hide
Siafoo is here to make coding less frustrating and to save you time. Join Siafoo Now or Learn More

Regular Expressions Atom Feed 3

In Brief Just a collection of common regular expressions I use with the .Net System.Text.RegularExpressions.RegEx object. Some of them haven't been extensively tested so if you spot a mistake please let me know!
# 's
 1// WARNING VB.NET DEVELOPERS: These are C# syntax strings so two back slashes (\\) actually means one so take heed when copying.
2
3SPECIAL_CHARACTERS = "`~!@#$%^&*()\\-_+={}\\\\|\\[\\]<>,.;:\"'?/";
4SINGLENAME_REGEX = "^([a-zA-Z\\-])+$";
5CURRENCY_REGEX = "^(\\$)?(([0-9]+)|([0-9][0-9]?[0-9]?(,[0-9][0-9][0-9])*)).[0-9][0-9][0-9]?$";
6STREET_REGEX = "^([Pp]\\.[Oo]\\. [Bb][Oo][Xx] [0-9a-zA-Z]+)|([1-9][0-9/]*( [a-zA-Z0-9\\-.&#]+)+)$";
7EMAIL_REGEX = "^[a-zA-Z0-9\\-_\\.]+@([a-zA-Z0-9\\-_]+\\.)+[a-zA-Z][a-zA-Z]+$";
8PHONE_REGEX = "^[\\(]?[0-9][0-9][0-9]([\\) \\-]|(\\) ))?[0-9][0-9][0-9]([\\-]|[ ])?[0-9][0-9][0-9][0-9]$";
9INTERNATIONAL_PHONE_REGEX = "^([+\\- ()]*[0-9][+\\- ()]*){10,15}$";
10DATE_REGEX = "^[01]?\\d[/-][0123]?\\d[/-]((19|20)?\\d\\d)$";
11URL_REGEX = "^(https?://)?(([a-zA-Z0-9\\-_])+\\.)+([a-zA-Z0-9\\-_])+(\\/[a-zA-Z0-9\\-_\\%]+)*((\\.[a-zA-Z0-9\\-_]+)|\\/)?(\\?.*)?$";
12ZIP_REGEX = "^[0-9][0-9][0-9][0-9][0-9](-?[0-9][0-9][0-9][0-9])?$";
13NUMBERSONLY_REGEX = "^[0-9]*";

Just a collection of common regular expressions I use with the .Net System.Text.RegularExpressions.RegEx object. Some of them haven't been extensively tested so if you spot a mistake please let me know!

Comments

over 8 years ago (21 Sep 2008 at 10:22 AM) by Theodore Test
Handy! A classic set of everyday regexs.
over 8 years ago (21 Sep 2008 at 11:58 AM) by Stou S.
I second that, they aren't even C# specific. Maybe there should be a regex language... oh wait, that's Perl.