From: steve at blighty.com (Steve Atkins)
Date: Sat, 24 Apr 1999 14:52:51 GMT
Subject: wrapped around the axle on regexpressions and file searching
References: <7frhe0$8g1$1@nnrp1.dejanews.com> <1287155028-45807148@hypernet.com>
Message-ID: <372ed9f3.497562737@192.168.1.1>
X-UID: 846                                                  

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





