This is bugging me:
Why preg_match('/pattern/', $haystack) instead of preg_match('pattern', $haystack)? Everything I've seen just states as a fact that they're necessary, and mentions that you can use alternate delimiters.
But, it's a function that defines its own interface outside of the string. It has a flags argument. Adding intra-string syntax seems capricious.
Is it something inherited from pcre that the authors were just not interested in working around? Yet another perverse fact of PHP? Or is there a justification?
$flagsargument in PHP's PCRE functions is not where you put modifiers, unlike theflagsargument in JavaScript'sRegExp()constructor.'s that appear at the beginning and end of the string. And I know that the$flagsisn't used for flags. That's just dumb.my_preg_match()which accepts a regex without delimiters and adds them, wrappingpreg_match()internally.