Regular expresion in php to search url with a given pattern

I want to search a given text for local urls in link’s href attributes, using regular expression. Curently I have a regular expression:

'/href=["']?([^"'>]+)["']?/'

but I’d like to add some more filtering:
Only get those links, which start like this:

XXXX-XX-XX

Where X is a number. This should match this: 2015-05-15/, 2015-05-15_03_21_32/ and also 2014-12-21 (any date set by me).

Thanks for the answers!


Source: regex

Leave a Reply