In article <[EMAIL PROTECTED]>, W. eWatson <[EMAIL PROTECTED]> wrote: >Is it possible to do a search for a wild card string in another string. For >example, I'd like to find "v*.dat" in a string called bingo. v must be >matched against only the first character in bingo, and not simply found >somewhere in bingo, as might be the case for "*v*.dat". . . . Does this session leave any questions:
python Python 2.4.4c0 (#2, Oct 2 2006, 00:57:46) [GCC 4.1.2 20060928 (prerelease) (Debian 4.1.1-15)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> pattern = "^v.*\.dat" >>> compiled = re.compile(pattern) >>> compiled.match("victory.dat") <_sre.SRE_Match object at 0xb7da2c60> >>> ms = compiled.match("victory.dat") >>> ms.group() "victory.dat" >>> compiled.match("avoid.dat") >>> # Notice the return value of "None". ... >>> import sys >>> sys.exit() ? -- http://mail.python.org/mailman/listinfo/python-list