开发者

how to check for special characters php [duplicate]

开发者 https://www.devze.com 2023-01-20 05:16 出处:网络
This question already has answers here: 开发者_如何学运维Closed 12 years ago. Possible Duplicate:
This question already has answers here: 开发者_如何学运维 Closed 12 years ago.

Possible Duplicate:

preg_match php special characters

Hi all, I want to check if these characters exist in a string by using preg_match:

^'£$%^&*()}{@'#~?><>,@|\-=-_+-¬'

Help please!


<?php

$string = 'foo';

if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $string))
{
    // one or more of the 'special characters' found in $string
}


preg_match('/'.preg_quote('^\'£$%^&*()}{@#~?><,@|-=-_+-¬', '/').'/', $string);

0

精彩评论

暂无评论...
验证码 换一张
取 消