Commits

Matt Chaput  committed 6008946

Fixed wildcard regex (should have used \w instead of \S). Fixes issue #116.

  • Participants
  • Parent commits a67fb76

Comments (0)

Files changed (2)

File src/whoosh/qparser/plugins.py

         return ((WildcardPlugin.Wild, 1), )
     
     class Wild(BasicSyntax):
+        # Any number of word chars, followed by at least one question mark or
+        # star, followed by any number of word chars, question marks, or stars
         # \u055E = Armenian question mark
         # \u061F = Arabic question mark
         # \u1367 = Ethiopic question mark
-        expr = rcompile(u"[^ \t\r\n*?\u055E\u061F\u1367]*[*?\u055E\u061F\u1367]\\S*")
+        expr = rcompile(u"\\w*[*?\u055E\u061F\u1367](\\w|[*?\u055E\u061F\u1367])*")
         qclass = query.Wildcard
         
         def __repr__(self):

File tests/test_parsing.py

     q = qp.parse(u"kind:(1d565 OR 7c584) AND (stuff)")
     assert_equal(unicode(q), "((kind:1d565 OR kind:7c584) AND content:stuff)")
 
+def test_star_paren():
+    qp = qparser.QueryParser("content", None)
+    q = qp.parse(u"(*john*) AND (title:blog)")
+    
+    assert_equal(q.__class__, query.And)
+    assert_equal(q[0].__class__, query.Wildcard)
+    assert_equal(q[1].__class__, query.Term)
+    assert_equal(q[0].fieldname, "content")
+    assert_equal(q[1].fieldname, "title")
+    assert_equal(q[0].text, "*john*")
+    assert_equal(q[1].text, "blog")
 
+