My problem might be solvable in other ways, but I can't help but wonder why it doesn't work using regex.
The code
#!/bin/bash
python_version=$(python3 --version)
regexp='(?<=^Python )3\.[0-9]+'
[[ $python_version =~ $regexp ]]
echo $BASH_REMATCH
should yield 3.8 for python version 3.8.10, for example. And it does, when I check it at regex101.com. But when I stick it in the bash, it does nothing.
I should note, that $python_version equals to Python 3.8.10 in this test case.
I would really like to know, how to solve this particular problem using bash only.
I'm using Ubuntu 20.04.