Validation with regular expressions: Allow two formats
September 11, 2009
Javascript
Actionscript
ASP.NET
Validation
Regular expressions
Snippet
Here's a nice piece of regular expression submitted by Nils that allow validation against two different formats, in this case 10 or 12 numbers:
^[0-9]{10}(?: [0-9]{2})?$
Related posts:
C#: Remove all non numeric characters from a string using Regex
3 must have tools for .net developers
Remove extra white-spaces within a string
Extract image tags from HTML in C#
Extend String with trim functions