Regular expressions are generally not intuitive.

Regular expressions in PHP are especially not intuitive.

In short, there are some special rules to writing regular expressions using PHP.  Here are some differences:

Delimiters

// Traditional - no delimiters necessary
.*

// PHP - use a pair of slashes (or other non-alpha/numerics)
/.*/

Character Classes

// Traditional - braces
.*.{gif|jpg|png}

// PHP - square brackets
/.*.[gif|jpg|png]/

Find out all of the details on the PHP site right here: