Repository: xonsh/xonsh

Issue:
Regex globbing broken for path including active regex characters
Paths including active regex characters such as `test+a/model` are not matched by regex globbing:

```xonsh
mkdir -p test/model
mkdir -p test+a/model
mkdir -p test*1/model
for d in `.*/model`:
    print(d)
```

Gives the following output

```output
test/model
```

## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**



Discussion:

Resolving patch:
diff --git a/xonsh/built_ins.py b/xonsh/built_ins.py
--- a/xonsh/built_ins.py
+++ b/xonsh/built_ins.py
@@ -20,7 +20,7 @@
 
 from xonsh.inspectors import Inspector
 from xonsh.lazyasd import lazyobject
-from xonsh.platform import ON_POSIX, ON_WINDOWS
+from xonsh.platform import ON_POSIX
 from xonsh.tools import (
     XonshCalledProcessError,
     XonshError,
@@ -92,12 +92,7 @@ def reglob(path, parts=None, i=None):
             base = ""
         elif len(parts) > 1:
             i += 1
-    regex = os.path.join(base, parts[i])
-    if ON_WINDOWS:
-        # currently unable to access regex backslash sequences
-        # on Windows due to paths using \.
-        regex = regex.replace("\\", "\\\\")
-    regex = re.compile(regex)
+    regex = re.compile(parts[i])
     files = os.listdir(subdir)
     files.sort()
     paths = []
@@ -105,12 +100,12 @@ def reglob(path, parts=None, i=None):
     if i1 == len(parts):
         for f in files:
             p = os.path.join(base, f)
-            if regex.fullmatch(p) is not None:
+            if regex.fullmatch(f) is not None:
                 paths.append(p)
     else:
         for f in files:
             p = os.path.join(base, f)
-            if regex.fullmatch(p) is None or not os.path.isdir(p):
+            if regex.fullmatch(f) is None or not os.path.isdir(p):
                 continue
             paths += reglob(p, parts=parts, i=i1)
     return paths


Test patch:
diff --git a/tests/test_builtins.py b/tests/test_builtins.py
--- a/tests/test_builtins.py
+++ b/tests/test_builtins.py
@@ -1,8 +1,10 @@
 """Tests the xonsh builtins."""
 import os
 import re
+import shutil
 import types
 from ast import AST, Expression, Interactive, Module
+from pathlib import Path
 
 import pytest
 
@@ -85,6 +87,41 @@ def test_repath_HOME_PATH_var_brace(home_env):
     assert exp == obs[0]
 
 
+# helper
+def check_repath(path, pattern):
+    base_testdir = Path("re_testdir")
+    testdir = base_testdir / path
+    testdir.mkdir(parents=True)
+    try:
+        obs = regexsearch(str(base_testdir / pattern))
+        assert [str(testdir)] == obs
+    finally:
+        shutil.rmtree(base_testdir)
+
+
+@skip_if_on_windows
+@pytest.mark.parametrize(
+    "path, pattern",
+    [
+        ("test*1/model", ".*/model"),
+        ("hello/test*1/model", "hello/.*/model"),
+    ],
+)
+def test_repath_containing_asterisk(path, pattern):
+    check_repath(path, pattern)
+
+
+@pytest.mark.parametrize(
+    "path, pattern",
+    [
+        ("test+a/model", ".*/model"),
+        ("hello/test+1/model", "hello/.*/model"),
+    ],
+)
+def test_repath_containing_plus_sign(path, pattern):
+    check_repath(path, pattern)
+
+
 def test_helper_int(home_env):
     helper(int, "int")