osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

for line3 in myips matching too longer matches.


###
CODE:
           elif line1.rstrip(?\n?) in line2.strip(?\n?):
               for line3 in myips:
                   print ?###?
                   print ?line1 is %s? % line1.rstrip(?\n?)
                   print ?line2 is %s? % line2.strip(?\n?)
###
OUTPUT:
line1 is 10.10.168.2
line2 is              - address: 10.10.168.27  # myhost
###

I think the problem is here: 
line1.rstrip(?\n?) in line2.strip(?\n?):  

I want it to
match only 10.10.168.2 AND 10.10.168.2:
NOT match 10.10.168.2[0-9]

If someone out there knows a simple solution. I would love to see it.
Thanks in advance. 
crzzy1