php - Problem with regex -
i have following regex:
/[0-9#%@_$&!?^\/|*<>]+/i
which not supposed accept letters. accept letters when letters not entered @ first place.
e.g.: finds match if enter "123e" (but should not because there letter)
what problem in regex?
thanks
your regex checks if there one or more of list characters specified -- , that's true 123e
.
it doesn't check if string contains only those.
might want edit regex, looks :
/^[0-9#%@_$&!?^/|*<>]+$/i
where i've added 2 following anchors :
^
indicating "beginning of string / line"$
indicating "end of string / line"
which means regex check if string starts 1 of characters, end 1 of those, , contains those.
Comments
Post a Comment