Check if a string matches a regular expression
suggest changeCheck 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents