I would like to check if a URL (or any string) contains any form of the following pattern ####-##-##
Does anyone have a handy str_replace() or regular expression to do that?
something like:
contains_date_string($string);
returns true if $string contains ####-##-##
Thank you!!!
If the word boundary (
\b) doesn’t do the trick, you could try negative lookbehind and lookaheads:As an additional validation, you could use
checkdate()to weed out invalid dates such as9999-02-31as mentioned in this answer.