fork download
  1. <?php
  2.  
  3. $exception = "(t%t+^$[]?\\).txt";
  4. echo $exception . "\n";
  5. $exception = preg_replace('/[()\[\]+$^*?\\\\{]/', '\\\$0', $exception);
  6. $reg = '/'.str_replace('%','[A-Za-z0-9_-]*', str_replace('.','\.',$exception)).'/i';
  7. echo $reg."\n";
  8. //TEST
  9. $str = "(t333t+^\$[]?\).txt";
  10. preg_match_all($reg, $str, $matches);
  11. print_r($matches);
  12.  
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
(t%t+^$[]?\).txt
/\(t[A-Za-z0-9_-]*t\+\^\$\[\]\?\\\)\.txt/i
Array
(
    [0] => Array
        (
            [0] => (t333t+^$[]?\).txt
        )

)