php - Allow whitespace, unicode letters, digits, underscore, dash AND comma? -
i'm pretty new @ subject preg , i'm using preg_match condition check if user has entered whitespace, unicode letters, digits, underscore or dash:
if(preg_match("/[^\040\pl\pn_-]/u", $term)) { but wanted allow comma. tried this:
if(preg_match("/[^\040\pl\pn,_-]/u", $term)) { and works , wanted know why. want understand better. why have ,_- , not -_, example allow comma?
i appreciate if explain me step step.
this because - used ranges in square brackets([] -> character classes). , manual: indicates character range, example: 0-9 or a-z.
so long put @ end you're fine , don't have escape it. in other cases have escape backslash e.g. \-.
means:
,_- //at end _,- //at end \-,_ //escape \-_, //escape ,\-_ //escape _\-- //escape
Comments
Post a Comment