Regular Expression Help for Date Validation - dd/mm/yyyy - PHP [duplicate]
This question already has an answer here: preg_match: check birthday format (dd/mm/yyyy) 11 answers Can someone show me the error of my ways when it comes to this regular expression: if(preg_match("/^[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}$/", $_POST["date"]) === 0) { echo 'error'; } Basically I want this to display an error message each time - unless the format is correct (dd/mm/yyyy). What am I doing wrong with the above? Many thanks for any pointers. -- updated regex above shortly after posting - apologies for inconvenience -- I think you should escape the slashes /^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$