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,997
  • 3
  • 28
  • 47
  • 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
}
Paulo Freitas
  • 13,194
  • 14
  • 74
  • 96