From: Tim Greer Date: 2009-01-07T09:20:10+09:00 Subject: Re: Simple Regexp help Joe Blow wrote: > How can I test a word to make sure it ONLY contains certain > characters? > > Say i have an expression like /[A-Z]/i > > How could i have "Testing" pass but "Testing123" fail? > > PS. I can not dynamically create the expression so it looks like this > /[A-Z{10}]/ If you only want a-z, set the character class to start and end the string, otherwise it'll match anything with a character that's in the alphabet, regardless of what follows it. I.e., /^[a-z]+$/i will only match a-z characters from start to end. You can then change the character class to whatever you wish. ^ is the start of the string and $ is the end of the string. + is one or more characters, so ^[a-z]+$ is one of more characters in the character class [], being a-z, and noting else. -- Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc. Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers and Custom Hosting. 24/7 support, 30 day guarantee, secure servers. Industry's most experienced staff! -- Web Hosting With Muscle!