944,110 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2107
  • PHP RSS
Mar 8th, 2006
0

regular expression

Expand Post »
so I am trying to write a regular expression lets just take this case for an example:
PHP Syntax (Toggle Plain Text)
  1. ^[0-9a-z]{5,9}$
OR an empty string, how would I add that part?

I tried stuff like:
PHP Syntax (Toggle Plain Text)
  1. ^([0-9a-z]{5,9}|[]{0})$
but to no avail, any ideas?
Similar Threads
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Mar 14th, 2006
0

Re: regular expression

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fisheye is offline Offline
11 posts
since Jan 2006
Mar 15th, 2006
0

Re: regular expression

^[0-9a-z]{5,9}$|^$
Reputation Points: 36
Solved Threads: 6
Posting Whiz
Troy is offline Offline
354 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC