|
Posted by Randell D. on 07/22/05 02:34
Folks,
I could do some basic regular expressions (which I picked up from sed,
in unix) but I'm afraid its been a while. I'm wondering if someone
could help out. I basically want to check that a string variable
contains only alphanumeric characters, in addition check for the
underscore. No decimal point check is required, and it should be a case
insensitive check.
I'm using PHP 4.x and would basically like to replace whatever is not
named above with an empty character (thus if a bang or question mark was
in a string, it would be removed from the string).
I know I could use something like preg_replace, but I don't know how to
say "when not found"... In sed, I could do something like
sed -e -i 's/[a-z]|[0-9]|_//g'
This would do the opposite of what I want to do (I think) but I'm lost
when it comes to PHP...
Can someone help me out, via the newsgroup (so all can learn?)
thanks in advance,
randell d.
Navigation:
[Reply to this message]
|