How do I match a .log but not .log* in regex or python? -


i having trouble regular expressions.

i have:

urls = re.findall(r'href=[\'"]?([^\'" >]+)', line) print urls 

which gives me:

['production_r1499.log'] ['production_r1499.log-20140323'] ['production_r1499.log-20140323.gz'] 

i interested in .log file. how regex match one?

alternatively. approach similar work?

if str(urls).endswith('.log'): 

happy , grateful suggestions!

try this.

urls = re.findall(r'href=[\'"]?([^\'" >]+\.log)', line) 

strictly speaking, should anchored end of href attribute. if concerned false positives, maybe add [\'">] before closing quote.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -