if (preg_match('(\p{Nd}{4}/\p{Nd}{2}/\p{Nd}{2}/\p{L}+)', '2010/02/14/this-is-something'))
{
// do stuff
}
The above code works. However this one doesn’t.
if (preg_match('/\p{Nd}{4}/\p{Nd}{2}/\p{Nd}{2}/\p{L}+/u', '2010/02/14/this-is-something'))
{
// do stuff
}
Maybe someone could shed some light as to why the one below doesn’t work. This is the error that is being produced:
A PHP Error was encountered
Severity: Warning
Message: preg_match()
[function.preg-match]: Unknown
modifier ‘\’
The
modifier uis available from PHP4.1.0or greater on Unix and from PHP4.2.3on win32.Also as nvl observed, you are using / as the delimiter and you are not escaping the / present in the regex. So you’lll have to use:
To avoid this escaping you can use a different set of delimiters like:
or