Re: simple regular expression problem?
| From: | Daniel Convissor | Date: | Mon, 27 Nov 2000 03:41:17 +0000 |
| Subject: | Re: simple regular expression problem? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27301@lists.php.net to get a copy of this message | ||
Hi Burnd:
Jason wrote:
>
> On Fri, Nov 24, 2000 at 10:08:06PM +0100, Bernd Duesmann wrote:
> >
> > a-z lower case
> > A-Z upper case
> > 0-9 and an underscore
> >
> > if there is another character in the string there should be an error
> > message.
>
> ereg("[_[:alnum:]]", $string);
Jason's on the right track. A few fixes:
First, place it in an if statement, because you asked to have it fail if
there's an error. Second, placing an ! before the ereg() has the if
statement kick in if the ereg() statement fails. Third, I'm going to ensure
that this ereg evaluates the entire string by placing a ^ at the beginning
and a $ at the end
if ( !ereg("^[[:alnum:]]$", $string) ) {
echo "you've got a problem.";
}
Enjoy,
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409