diff --git a/functions/_tide_item_python.fish b/functions/_tide_item_python.fish
index 57f7075a..2e351703 100644
--- a/functions/_tide_item_python.fish
+++ b/functions/_tide_item_python.fish
@@ -9,7 +9,7 @@ function _tide_item_python
# pipenv $VIRTUAL_ENV looks like /home/ilan/.local/share/virtualenvs/pipenv_project-EwRYuc3l
# Detect whether we are using pipenv by looking for 'virtualenvs'. If so, remove the hash at the end.
if test "$dir" = virtualenvs
- string match -qr "(?.*)-.*" $base
+ string match -qr "(?[^/-]*)" $base
_tide_print_item python $tide_python_icon' ' "$v ($base)"
else if contains -- "$base" virtualenv venv .venv env # avoid generic names
_tide_print_item python $tide_python_icon' ' "$v ($dir)"
diff --git a/tests/_tide_item_python.test.fish b/tests/_tide_item_python.test.fish
index 11760529..46514065 100644
--- a/tests/_tide_item_python.test.fish
+++ b/tests/_tide_item_python.test.fish
@@ -21,6 +21,9 @@ _python # CHECK: 3.11.5 (python_project)
set -lx VIRTUAL_ENV /home/ilan/.local/share/virtualenvs/pipenv_project-EwRYuc3l
_python # CHECK: 3.11.5 (pipenv_project)
+set -lx VIRTUAL_ENV /home/ilan/.local/share/virtualenvs/pipenv_project
+_python # CHECK: 3.11.5 (pipenv_project)
+
set -l python_directory (mktemp -d)
cd $python_directory