Logical "or" with RegularExpressions

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

???
 
M

mg

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


.
 
K

Ken Cox [Microsoft 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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top