Page 2 of 2
Posted: Fri Sep 10, 2004 2:59 pm
by Christopher
You are correct. It should be:
'/[^a-zA-Z]/' is all characters that are not a-z or A-Z
'/[^0-9\-]/' is all characters that are not 0-9 or dash
Posted: Fri Sep 10, 2004 3:07 pm
by feyd
arborint wrote:You are correct. It should be:
'/[^a-zA-Z]/' is all characters that are not a-z or A-Z
'/[^0-9\-]/' is all characters that are not 0-9 or dash
only matches 1 character.. any character in the string.
Posted: Fri Sep 10, 2004 4:54 pm
by Christopher
No, it will remove all occurances that are not in the set given. For example:
$str = preg_replace('/[^a-zA-Z]/', '', $str);
will remove all characters except letters. It's probably the most generic way to filter strings.
Posted: Fri Sep 10, 2004 4:56 pm
by feyd
with replace yes, I was talking about matching.