PHP Regex Unknown Modifier -
read ton, didn't see answer. sorry if duplicate.
running php 5.4.
i have form takes contact info (name, email, number, etc).
the regex is: allow letters, numbers, space, dash, backslash, colon, @ sign, , forward slash.
this i'm using (for input values, showing 1 below):
if (!preg_match("/^[./\\@\w\sa-za-z0-9:-]+$/", $_post["name"]) i keep getting unknown modifier error. don't care if above fixed, or replaced different regex, need allow things mentioned earlier.
thanks in advance.
you need escape /
this should be
^[.\/\\@\w\sa-za-z0-9-]+$ test regex pattern @ regex101
\smatch white space character[\r\n\t\f ]if looking space use\wmatch word character[a-za-z0-9_]includes underscore well. remove regex pattern
only allow letters, numbers, space, dash, backslash, colon, @ sign, , forward slash.
it should ^[0-9a-za-z \\:@\/-]+$
note: make sure hyphen - must in beginning or ending of character class or should escaped because hyphen has special meaning in character class define range.
Comments
Post a Comment