Commits

Matt Chaput committed a28f5d3

Use whitespace class instead of literal space in operator regexes. See issue #253.

Comments (0)

Files changed (1)

src/whoosh/qparser/plugins.py

             return self.optype(match.group(0), self.grouptype, self.leftassoc)
 
     def __init__(self, ops=None, clean=False,
-                 And=r"(?<= )AND(?= )",
-                 Or=r"(?<= )OR(?= )",
-                 AndNot=r"(?<= )ANDNOT(?= )",
-                 AndMaybe=r"(?<= )ANDMAYBE(?= )",
-                 Not=r"(^|(?<=[ \r\n\t()]))NOT(?= )",
-                 Require=r"(^|(?<= ))REQUIRE(?= )"):
+                 And=r"(?<=\s)AND(?=\s)",
+                 Or=r"(?<=\s)OR(?=\s)",
+                 AndNot=r"(?<=\s)ANDNOT(?=\s)",
+                 AndMaybe=r"(?<=\s)ANDMAYBE(?=\s)",
+                 Not=r"(^|(?<=(\s|[()])))NOT(?=\s)",
+                 Require=r"(^|(?<=\s))REQUIRE(?=\s)"):
         if ops:
             ops = list(ops)
         else: