regular expression

Reply

Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

regular expression

 
0
  #1
Mar 8th, 2006
so I am trying to write a regular expression lets just take this case for an example:
  1. ^[0-9a-z]{5,9}$
OR an empty string, how would I add that part?

I tried stuff like:
  1. ^([0-9a-z]{5,9}|[]{0})$
but to no avail, any ideas?
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 11
Reputation: fisheye is an unknown quantity at this point 
Solved Threads: 0
fisheye's Avatar
fisheye fisheye is offline Offline
Newbie Poster

Re: regular expression

 
0
  #2
Mar 14th, 2006
My suggestion would be to avoid putting so much overhead in the regular expression engine for such a simple test. You can accomplish what you want in PHP by doing something like:
[PHP]
# Assuming you are testing $string...
if(preg_match('/^[0-9a-z]{5,9}$/',$string) || strlen($string) < 1) {
# Do things here.
}
[/PHP]
How about that?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: regular expression

 
0
  #3
Mar 15th, 2006
^[0-9a-z]{5,9}$|^$
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC