I feel I have a basic understanding of regex but I came across this conditional in our codebase the other day and I can't get my head around it:
if ($content && !preg_match('/{\w+}/', $content->title))
I was under the impression that the curly braces were min/max ranges and thus the \w+
doesn't really work inside but it doesn't error.
Currently it is letting through a $content->title
of Unsubscribe
which makes sense for our application, but would presumably match /\w+/
.
Can anyone shed any light on this or should I rewrite it to something more sensible?