0

preg_match() will return

preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash

if the pattern is not well-formed. Is there a function to determine (TRUE or FALSE) if the pattern is well-formed before passing it preg_match()?

alberto56
  • 2,759
  • 2
  • 27
  • 41
  • Try reading documentation > http://php.net/manual/bg/function.preg-match.php if there is error it will return False. – Svetoslav Oct 17 '13 at 12:45

1 Answers1

0
$match = preg_match('regex', 'string');

if ($match === false) {
    // failed
} elseif ($match == false) {
    // did not matched
} else {
    // matched
}
user222758
  • 12,347
  • 13
  • 71
  • 93