regex - PHP Regular Expression pattern accepts characters that are not allowed -
preg_match('~^[a-za-z0-9!@#$%^*()-_+=.]+$~', $string)
this pattern used in code, wanted telling users they're allowed use these characters. problem works characters , not others. example doesn't allow string "john&john" allows "test<>" though didn't enter '<' , '>' in pattern!
i test regexps tools https://regex101.com/
you must escape special characters in regexp:
^[a-za-z0-9!@#\$%\^\*\(\)\-_\+=\.]+$