I am trying to search for a word out of these 2 Principles.
But by code displays both of the principles not just one.
How could I make it display only the principle where the word is located.
import re
patterns = [ 'work' ]
text = """\
1. Principle of Segmentation:
a) Divide an object into independent parts
- Replace a large truck by a truck and trailer.
- Use a work breakdown structure for a large project.
- Sequential novel turn into movies
b) Make an object easy to disassemble.
- Bicycle disassembling (saddle, wheels)
- Furniture (sofas, table)
- Crib
c) Increase the degree of fragmentation or segmentation.
- Replace solid shades with Venetian blinds
- Computer covers with holes for ventilation
- Multi blade cartridge Razor
4. Principle of Asymmetry:
a. If an object is symmetrical, change its shape to irregular.
-Asymmetric paddles mix
-cement
-truck
-blender
-cake mixer
"""
for pattern in patterns:
print 'Looking for "%s" in "%s" ->' % (pattern, text),
if re.search(pattern, text):
print 'found a match!'
else:
print 'no match'