>>> line1 = 'start address: 0xA0, func1 address: 0xC0'
>>> line2 = 'end address: 0xFF, func2 address: 0xB0'
>>> bool(re.search(r'0xB0', line1))
False
>>> bool(re.search(r'0xB0', line2))
True
>>> ip = 'They ate 5 apples and 5 oranges'
>>> re.sub(r'5','five',ip)
'They ate five apples and five oranges'
>>> items = ['goal', 'new', 'user', 'sit', 'eat', 'dinner']
>>> [w for w in items if not re.search(r'e',w)]
['goal', 'sit']
>>> ip = 'This note should not be NoTeD'
>>> re.sub(r'note','X',ip,flags=re.I)
'This X should not be XD'
>>> para = '''good start
... Start working on that
... project you always wanted
... stars are shining brightly
... hi there
... start and try to
... finish the book
... bye'''
>>> pat = re.compile(r'start',flags=re.I)
>>> for line in para.split('\n'):
... if not pat.search(line):
... print(line)
...
project you always wanted
stars are shining brightly
hi there
finish the book
bye
>>> items = ['goal', 'new', 'user', 'sit', 'eat', 'dinner']
>>> [w for w in items if re.search(r'a',w) or re.search(r'w',w)]
['goal', 'new', 'eat']
>>> items = ['goal', 'new', 'user', 'sit', 'eat', 'dinner']
>>> [w for w in items if re.search(r'e',w) and re.search(r'n',w)]
['new', 'dinner']