so I am trying to write a regular expression lets just take this case for an example:

^[0-9a-z]{5,9}$

OR an empty string, how would I add that part?

I tried stuff like:

^([0-9a-z]{5,9}|[]{0})$

but to no avail, any ideas?

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:

# Assuming you are testing $string...
if(preg_match('/^[0-9a-z]{5,9}$/',$string) || strlen($string) < 1) {
# Do things here.
}

How about that?

^[0-9a-z]{5,9}$|^$

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.