Exclusion in Regex not working
| From: | SLanger at spirit21 dot de | Date: | Fri, 31 Jan 2003 13:11:34 +0000 |
| Subject: | Exclusion in Regex not working | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-133762@lists.php.net to get a copy of this message | ||
Hello Everyone
This might be slightly offtopic since I'm not sure its php related but....
I'm working on a script where some inputdata is taken for further
processing. For validation purposes I want to make sure certain chars are
not part of the input. Basically stuff like $ * :; etc...
So I'm using ereg(pattern, input) to see if the pattern matches or not.
Example
if(ereg($pattern, $input))
{
// do allowed stuff
}
else
{
// do something for the illegal input
}
SO for exclusion I build the following pattern [^$] and pass it to ereg
above. So if the input includes a $ the ereg should return false and the
processing shouldn't take place.
Well the thing is for $pattern = '[^$]' it doesn't work. Input including
'$' is still passed to the allowed stuff code block.
So am I doing something wrong or is there a problem with the character
coding of my editor
BtW I'm using W2K with PHP 4.1.x Apache 1.3.X and TextPad 4.x for editing.
I save my scripts as ANSI format. Meaning only legal ASCII Characters +
German extended code page.
Can anybody help me?
I also tried [^a] as a pattern but the input can contain a and slip
through.