I am using regex in GNU bash, version 4.4.23(1)-release (x86_64-pc-msys) (git bash).
I am having an issue indicating a colon to the regex.
I am looking for the following string:
Date : 25 Dolahn(6)
Using the following regex:
if [[ "$_line" =~ Date : (.*) ]]; then
echo $_line
_date=${BASH_REMATCH[1]}
fi
I get the following error:
parse.sh: line 47: syntax error in conditional expression
parse.sh: line 47: syntax error near `:'
parse.sh: line 47: ` if [[ "$_line" =~ Date : (.*) ]]; then'
According to this short answer, there is no escaping necessary for a colon (and it throws the same error anyway).
I also tried putting it into "[]", with the same error.
What am I doing wrong with this regex ? How do I indicate the colon ?