In bash, I'm trying to capture this groups with this regex but BASH_REMATCH give me empty results
RESULT="1730624402|1*;[64452034;STOP;1730588408;74;22468;1"
regex="([[:digit:]]+)?|([[:digit:]])*;\[([[:digit:]]+)?;STOP;([[:digit:]]+)?;"
if [[ "$RESULT" =~ $regex ]]
then
echo "${BASH_REMATCH}" # => 1730624402
echo "${BASH_REMATCH[1]}" # => 1730624402
echo "${BASH_REMATCH[2]}" # EMPTY
echo "${BASH_REMATCH[3]}" # EMPTY
echo "${BASH_REMATCH[4]}" # EMPTY
else
echo "check regex"
fi
Where I go wrong?
Thanks in advance
BASH_REMATCH[]|and*as they are not interpreted literally. Tryregex='([[:digit:]]+)?\|([[:digit:]])\*;\[([[:digit:]]+)?;STOP;([[:digit:]]+)?;'RESULT="${RESULT//[!0-9]/ }"