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!@#\$%\^\*\(\)\-_\+=\.]+$ 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -