Reputation: 147
python 2.7.3: I'm sure I'm missing something simple but not able to figure it out I have a text file and I am reading file line by line:
dnsfile = open(self.logfile, "r")
for i, line in enumerate(dnsfile):
each line i am matching for some pattern:
match = re.search(r'(.*mail.*?) (.*) NS (.*)', line)
if match:
print "Matched"
else:
print "No match"
I am getting "No match" for all in file I have following lines which i am looking :
outlook.mail.com. 269 NS ns1.msft.net.
mailxyz.com. 123695 NS adns1.apple.com
I am trying same pattern and line on http://pythex.org/ and its matching but not with this code.
Upvotes: 0
Views: 1010
Reputation: 168626
You have tabs, not spaces, in your DNS file. Try this:
match = re.search(r'(.*mail.*?)\s+(.*)\s+NS\s+(.*)', line)
Upvotes: 1