简体   繁体   中英

PHP regexp match slash

I have the following regular expression tested at regex101 and it works there. However, when I try to use it inside the preg_match it doesn't work anymore. The problem is the slash: I tried escaping it but I can't get it working.

preg_match("/[<>\\\"'%;()&]/", "my\string");

The set of characters that I should match are:

< > \ " ' % ; ( ) &

只需使用不同的分隔符:

preg_match("![<>\\\"'%;()&/]!", "my\string");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM