Python sqlite and regex.

Paul McGuire ptmcg at austin.rr._bogus_.com
Fri May 19 14:00:53 EDT 2006


"John Salerno" <johnjsal at NOSPAMgmail.com> wrote in message
news:4Anbg.2134$No6.46516 at news.tufts.edu...
> Paul McGuire wrote:
> > "Paul McGuire" <ptmcg at austin.rr._bogus_.com> wrote in message
> > news:hunbg.46845$CH2.29994 at tornado.texas.rr.com...
> >
> >> where '*' matches one or more characters, and '?' matches any single
> >
> > oops, I meant '*' matches zero or more characters.
>
> '?' also matches 0 characters

Maybe it does, and maybe it doesn't... :)

Here is my test with the glob module (in my directory, there is a file named
PUTTY.RND):
>>> glob.glob('PUTTY.RND')
['PUTTY.RND']
>>> glob.glob('PUTTY.RN?')
['PUTTY.RND']
>>> glob.glob('PUTTY.RN?D')
[]
>>> glob.glob('PUTTY.RN?')
['PUTTY.RND']
>>> glob.glob('PUTTY.RND?')
[]
>>> glob.glob('PUTT?.RND')
['PUTTY.RND']
>>> glob.glob('PUTTY?.RND')
[]
>>> glob.glob('PUTT?Y.RND')
[]
>>>

Looks like '?' does *not* match zero characters in glob.  On the other hand,
in the Windows console window, it appears that '?' *does* match zero
characters.

Of course, you could write your regexp() routine to interpret '?' any way
you wanted.

-- Paul





More information about the Python-list mailing list