in reply to Re: Regular Expression - Need HElp..pls
in thread Regular Expression - Need HElp..pls

Shouldn't that be

m/ \A (?: [[:alpha:][:digit:]] [[:alpha:][:digit:]-]* )? \z /x

Your version requires that at least one character be present.

Replies are listed 'Best First'.
Re^3: Regular Expression - Need HElp..pls
by davido (Cardinal) on Feb 16, 2006 at 18:01 UTC

    You could be right. But since the OP doesn't specify whether or not the string must contain at least one character, I'd say that there is sufficient ambiguity in the definition of the problem that there's about an equal chance that mine is right. Good observation. Now the OP can choose which meets his needs.


    Dave