wrapped around the axle on regexpressions and file searching
Steve Atkins
steve at blighty.com
Sat Apr 24 10:52:51 EDT 1999
On Sat, 24 Apr 1999 15:21:03 GMT, "Gordon McMillan"
<gmcm at hypernet.com> wrote:
>msrisney writes:
>> here are my questions: 1. this prints out not only files with the
>> file extensions ".log" but also any file name that has "log" in it's
>> name. how would I rewrite to avoid??
>
>In a regex, a "." is a wildcard character. If you want a literal "."
>you need to escape it:
> re.compile('\\.log')
>or
> re.compile(r'\.log')
Wouldn't that be re.compile('\\.log$'), so as to avoid things like
tree.log.jpg?
doesn't-yet-grok-python-but-does-grok-regexps-ly y'rs
Steve
--
-- Steve Atkins -- steve at blighty.com
More information about the Python-list
mailing list