I am trying to grab part of a path in bash:
Entrance: /Users/foo/.virtualenvs/venv-test-server
code:
#!/bin/zsh
regex="^.*\/venv-(.*)$"
if [[ $VIRTUAL_ENV =~ $regex ]] ; then
echo "Matched!"
echo ${BASH_REMATCH[1]}
fi
Output: Matched!
But the match is not printed. Why?
source
to share