.gitlab-ci.yml regex to check gitlab varible

Trying to get the following regex to check the commit tag.

check:
    stage: check
    script:
    - echo "Checking if commit tag is valid"
    - [[ $CI_COMMIT_TAG =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$ ]] && echo "Git commit tag valid" || echo "Git commit tag not valid" && exit 1
    only:
    - tags

I get the error:

Status: syntax is incorrect 

Error: (<unknown>): did not find expected alphabetic or numeric character while scanning an alias at line 16 column 42