[thelist] RegEx problem again

Chris at globet.com Chris at globet.com
Mon Aug 8 11:00:05 CDT 2005

> > Which worked just fine, till we realized we need to allow 
> one or more 
> > SPACES as well! How do you add a space to the pattern? (and 
> allow for 
> > as many spaces as they like?)
> I am not a regex expert, but generally it depends on what 
> implementation you are using.

I believe that the implementation was javascript. In this case \s will
match one instance of any whitespace character (space, tab, line feed
etc). Thus, the following will suffice:

var namematch = /^[a-zA-Z\s]{3,}$/.test(nametext.value);
namematch = (namematch  || /^[a-zA-Z\*\s]{4,}$/.test(nametext.value));


Chris Marsh
Web Developer
Tel: +44 20 8246 4804 Ext 828
Fax: +44 20 8246 4808

Any opinions expressed in this email are those of the individual and not
necessarily the Company. This message is intended for the use of the
individual or entity to which it is addressed and may contain
information that is confidential and privileged and exempt from
disclosure under applicable law. If the reader of this message is not
the intended recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly prohibited.
If you have received this communication in error, please contact the
sender immediately and delete it from your system. 

More information about the thelist mailing list