.NET Framework Bookmark and Share   
 index > Regular Expressions > Multiple Length Checks
 

Multiple Length Checks

I'm Stumped!

Not sure if this is too difficult but have a requirement that a textbox can have only 9 or 11 digitvalue in length. It cannot be 10 in length. Optionally, it can multiple instances of 9 or 11 digit values that have a comma in between. No characters are allowed

for example, the followingare valid.

123456789
12345678912
123456789,12345678912,123456789

these are invalid

123,123456789
123456789,123456789123

AndrewLWong
I figured it out myself -

^((\d{11}|\d{9})(,)?(\s)*)+$

AndrewLWong

You can use google to search for other answers

Custom Search

More Threads

• Want to match any hex string except 0*
• replace and insert ines whir regexp
• need regular expression to not include strings contains a special charchters
• Re: tokenizing a csv file with embedded commas
• problem splitting a file
• Replacing \ with / using Regex.Replace C#
• negative lookbehind?
• Regular expression for parenthesis
• conditional split HELP!
• Substring with regex??