fork download
  1. <?php
  2.  
  3. $re = "/(?<!`)`([^`\\n\\r]+)`(?!`)/";
  4. $str = <<<EOT
  5. `match_1` // matches
  6. ``test`` // does NOT match
  7.  
  8. // does NOT match
  9. ```java
  10.   test
  11. ```
  12. `match_2`
  13.  
  14. Text `match_3`
  15.  
  16. Text `match_4`EOL
  17.  
  18. `match_5` sdsdfsdf `match_6`
  19. EOT;
  20.  
  21. preg_match_all($re, $str, $matches);
  22.  
  23. foreach ($matches[1] as $match) {
  24. echo "$match\n";
  25. }
  26. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
match_1
match_2
match_3
match_4
match_5
match_6