Check if a string matches a regular expression

suggest change

Check if a string consists in exactly 8 digits:

$ date=20150624
$ [[ $date =~ ^[0-9]{8}$ ]] && echo "yes" || echo "no"
yes
$ date=hello
$ [[ $date =~ ^[0-9]{8}$ ]] && echo "yes" || echo "no"
no

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents