The tests showed that the original implementation actually never worked.
You did NOT get a rehash after doing pip3.8 install, even when the
comments in the code said so.
--> replaced `\d` with [0-9] and slapped on a `+`, such that we match
both pip3.x and `pip3.xx install`
Instead of creating a for-loop where we go through each argument, to
check if current argument is -m and next argument is pip, we instead do
simple regex matching where we look for ` -m pip ` somewhere in the
command which is to be executed.
When doing `pip install ...`, the command is redirected to
`pyenv.d/exec/pip-rehash/pip`, which does a `pyenv rehash` after
installation. A simple fix to issue #3031 is to make `python -m pip`
commands go through the same special hook script.