13 March 2013

Python match|search Example


## python2.7

import re

mess = open("/var/log/messages", "r")

for line in mess:
    if re.match("(.*)(U|u)sb(.*)", line):
        print line,

''' Print the line that have a word Usb or usb ; ) '''

biOos

No comments: