programming-examples/python/Regular_Expression/Find the substrings within a string.py

5 lines
172 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
import re
text = 'Python exercises, PHP exercises, C# exercises'
pattern = 'exercises'
for match in re.findall(pattern, text):
print('Found "%s"' % match)