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
Post a Comment