I have a strange question maybe you could help me with. I am trying to check whether the given string contains special characters. The code below is working however one character seems to get exempted on the condition which is the square brackets [ ]. Can you help me with this? thank you.
    $string = 'starw]ars';
    if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $string)) {
        echo 'Output: Contains Special Characters';
    }else{
        echo 'Output: valid characters';
    }
Please note: I can't use below condition since I need to accept others characters from other languages like in arabic, chinese, etc. so it means I need to specify all characters that is not allowed.
    if (!preg_match('/[^A-Za-z0-9]/', $string))
Appreciate your help. Thanks.
 
     
     
     
    