fork download
  1. <?php
  2. $str1 = '%100';
  3. $str2 = '%100\%';
  4. $str3 = "100\\\\%";
  5. $str4 = "%100\\%%";
  6. $str5 = '100\%';
  7. $str6 = "100\\\\\\\\%";
  8. $str7 = "100\\\\\\%";
  9. $str8 = "100\\\\\\\\\\\\%";
  10. $str9 = "100\\\\\\\\\\\\\\%";
  11.  
  12. $reg_exp= '/^%|[^\x5C]%|[^\x5C](\x5C\x5C)+%/';
  13.  
  14. echo $str1.' = '.preg_match($reg_exp, $str1).', ';
  15. echo $str2.' = '.preg_match($reg_exp, $str2).', ';
  16. echo $str3.' = '.preg_match($reg_exp, $str3).', ';
  17. echo $str4.' = '.preg_match($reg_exp, $str4).', ';
  18. echo $str5.' = '.preg_match($reg_exp, $str5).', ';
  19. echo $str6.' = '.preg_match($reg_exp, $str6).', ';
  20. echo $str7.' = '.preg_match($reg_exp, $str7).', ';
  21. echo $str8.' = '.preg_match($reg_exp, $str8).', ';
  22. echo $str9.' = '.preg_match($reg_exp, $str9).', ';
  23. ?>
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
%100 = 1, %100\% = 1, 100\\% = 1, %100\%% = 1, 100\% = 0, 100\\\\% = 1, 100\\\% = 0, 100\\\\\\% = 1, 100\\\\\\\% = 0,