473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Logical "or" with RegularExpressions

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

???

Nov 18 '05 #1
3 1331
mg@theworld.com wrote:
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
Nov 18 '05 #2
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-----
mg@theworld.com wrote:
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
.

Nov 18 '05 #3
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/U...1-4EE2729D7322

Let us know?
<mg@theworld.com> wrote in message
news:02****************************@phx.gbl...
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

???


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
4
by: Smitro | last post by:
Hi, How come in some statements I can use: If (something) or DIE(); but other times it won't work (returns an error) unless I take out the OR. Is there any documentation on this anywhere?
2
by: mg | last post by:
Is there a Regular Expression that matches either an integer + OR some letters + followed by a COMMA followed by some letters + That is, for example, either 01234 OR aBc,xyZ ???
1
by: Guadala Harry | last post by:
The following function, SplitTheString(), splits a string based on a flag that is like this: {Flag1:whateverHere} Note that the "whateverHere" part can be any character - and at least one...
20
by: DraguVaso | last post by:
Hi, As a former VB-programmer I'm used to the "on error goto"-errorhandling. I see that in actually all the VB.NET-samples I can fin people use the "Try - catch"-errorhandling. Which of the...
5
by: comp.lang.php | last post by:
$orderBy = 's.app_date desc, s.last_name asc, s.first_name asc, s.mi asc'; if ($_REQUEST) { $ascArray = array('asc' => 'desc', 'desc' => 'asc'); // ARRAY OF ALL ORDERING POSSIBILITIES $junk =...
5
by: ano | last post by:
Hi, I have converted this VB code to C# but I got this error: "Operator '||' cannot be applied to operands of type 'int' and 'short'" Is VB allow to use Operator "Or" with 'int'? If yes, how...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
6
by: Russ P. | last post by:
I've always appreciated Python's lack of requirement for a semi-colon at the end of each line. I also appreciate its rules for automatic line continuation. If a statement ends with a "+", for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.