Logical "or" with RegularExpressions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a Regular Expression that matches either an
integer [0-9]+ OR some letters [a-zA-Z]+ followed by a
COMMA followed by some letters [a-zA-Z]+

That is, for example, either 12345 OR aBc,xyZ

???
 
I wasn't able to get an answer from the Web sites
suggested vbelow.

Does anyone have a solution to my specific OR question?

-----Original Message-----
Is there a Regular Expression that matches either an
integer [0-9]+ OR some letters [a-zA-Z]+ followed by a
COMMA followed by some letters [a-zA-Z]+
That is, for example, either 12345 OR aBc,xyZ

Check out the following web site for examples:
http://www.regexlib.com/

Also, here is a cheat sheet for Regular Expressions
http://www.regexlib.com/CheatSheet.htm

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP


.
 
The pipe character (|) is used for OR. I'm still learning regular
expressions, but here's a stab at it:

^[0-9]+$|^[a-zA-Z]+[,]{1}[a-zA-Z]+$

Basically it says, "Any character in 0 to 9 OR any letter (upper or lower
case) as many times as you like but must be followed by a comma and then
more letters."

BTW, a great tool for working these out is Regular Expression Workbench
which is free here:

http://www.gotdotnet.com/Community/...mpleGuid=C712F2DF-B026-4D58-8961-4EE2729D7322

Let us know?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Logical OR with RegularExpressions 2
Question on RegularExpression 1
Regular Expression Help 2
RegularExpression? 1
Regular Expressions? 5
Regular expression 4
Regular expression 4
RegularExpression Validator? 3

Back
Top