Hướng dẫn check special character php

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!

Hướng dẫn check special character php

SharpC

6,3384 gold badges42 silver badges39 bronze badges

asked Oct 14, 2010 at 22:12

4

<?php

$string = 'foo';

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

answered Oct 14, 2010 at 22:20

chigleychigley

2,49219 silver badges18 bronze badges

3

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

answered Oct 15, 2010 at 1:47

PetahPetah

44.5k27 gold badges155 silver badges211 bronze badges

1

Not the answer you're looking for? Browse other questions tagged php or ask your own question.