fork download
  1. <?php
  2.  
  3. function test($s)
  4. {
  5. echo $s . " : ";
  6. if (preg_match('|test/create/[^/]+$|', $s))
  7. echo "match.\n";
  8. else
  9. echo "does not match.\n";
  10. }
  11.  
  12. function test2($s)
  13. {
  14. echo $s . " : ";
  15. if (preg_match('^test/create/\d+$^', $s))
  16. echo "match.\n";
  17. else
  18. echo "does not match.\n";
  19. }
  20.  
  21. test('test/create/1234');
  22. test('test/create/1234/');
  23. test('test/create/1234/5678');
  24.  
  25. test2('test/create/1234');
  26. test2('test/create/1234/');
  27. test2('test/create/1234/5678');
  28.  
  29. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
test/create/1234 : match.
test/create/1234/ : does not match.
test/create/1234/5678 : does not match.
test/create/1234 : match.
test/create/1234/ : does not match.
test/create/1234/5678 : does not match.