Logical OR with RegularExpressions

  • Thread starter Thread starter mg
  • Start date Start date
M

mg

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 01234 OR aBc,xyZ

???
 
I think i'm parsing words to literally so that regex would have to look like
([0-9]+|[A-Za-z]+,[A-Za-z]+)
or shorthand
(\d+|\w+,\w+)

ps: not trying to show up mr gunnerson, of course

--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
(e-mail address removed)-software.com [remove the first "CC."]

Eric Gunnerson said:
The OR operator is "|", inside of parenthesis:

(cat|dog)

For what you want, you can do:

[0-9a-zA-Z]+,[a-zA-Z]+

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
mg said:
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 01234 OR aBc,xyZ

???
 
Back
Top