wurmy at earthlink.net
Sat Nov 10 00:45:35 CET 2001
Adonis Vargas wrote:
> i posted a thread before asking help on how to find a specific string within
> a line of string, i unfortunately did not get too specific on what i was
> asking for. how can i do a search within a string using wildcards?
> if "*something*is*" in "something is written here": return true
> ive looked into the re module and have been to the how-to pages, but i cant
> seem to understand it.
I suppose that, for a simple case like this, you can (ab)use the fnmatch module:
>>> import fnmatch
>>> fnmatch.fnmatch('something is written here', '*something*is*')
>>> fnmatch.fnmatch('something was written here', '*something*is*')
For more sophisticated stuff, you'll really need the re module, though (or
something with similar power).
More information about the Python-list