title: BASH_REMATCH doesn't capture
body: <p>I'm trying to capture a part of a path in bash:</p>
  
  <p>Input: <code>/Users/foo/.virtualenvs/venv-test-server</code></p>
  
  <p>Code:</p>
  
  <pre><code>#!/bin/zsh
  regex="^.*\/venv-(.*)$"
  if [[ $VIRTUAL_ENV =~ $regex ]] ; then
    echo "Matched!"
    echo ${BASH_REMATCH[1]}
  fi
  </code></pre>
  
  <p>Output: <code>Matched!</code></p>
  
  <p>But the match isn't printed. Why?</p>