php - preg_match: All characters must match -


i have user input gets checked if chars on whitelist.

my regular expression:

[a-za-z0-9_~\-!@#\s\$%\^&\*\(\)\=\:\;\+\°\´\[\]\{\}\§\"\'\ß\ä\ö\ü\%\.\,\>\<\|\€]+$ 

my code part:

$check = preg_match($pattern, trim($input)); 

now, when $input variable has example value abc²³, input gets blocked. when has value abc²³def, content won't blocked.

how can check every character of string?

you forgot start of string anchor: ^

^[\p{l}\d_~\-!@#\s$%^&*()=:;+°´\[\]{}§"'%.,><|€]+$ 

i simplified regex. note replaced a-za-zßäöü \p{l} accept letters language.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -