title: PHP preg_match check for dynamic set of special characters?
body: <p>In an application i need to do a special character check for dynamic set of special characters that is taken from db.I have tried the following, but it doesnt work,any help will be appreciated.</p>
  
  <pre><code>$specialCharacters = SystemParameters::model()-&gt;findByAttributes(array('sys_param_name' =&gt; 'SPLCHR'));
  // [\^Â£$%&amp;*()}{@#~?&gt;&lt;&gt;,|=_+Â¬-]'"; This is the resulting value
  $var = addslashes($specialCharacters-&gt;sys_param_val);
  
  if (preg_match('/' . $var . '/', $string))
      return false;
  else
      return true;
  </code></pre>