php - How to preg_match for a specific pattern in a url? -


i use preg_match in php test format of url. url looks this:

/2013/09/05/item-01.html 

i'm trying work :

if (preg_match("/([0-9]{4})\/([0-9]{2})\/([0-9]{2})/[.]+[.html]$", $_server['request_uri'])) :     echo "match"; endif; 

but something's not quite right. ideas?

try:

if (preg_match('!\d{4}/\d{2}/\d{2}/.*\.html$!', $_server['request_uri'])) {     echo 'match'; } 

\d short [0-9] , can use different start/end delimiters (i use ! in case) make regexp more readable when you're trying match slashes.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -