Contact: aviboots(AT)netvision.net.il
40,774 questions
53,162 answers
573 users
import re s = 'xyxxxyyyxyxxyy' pattern = 'xy{1,2}' # 'x' followed by one to two 'y' for match in re.findall(pattern, s): print('Found: {!r}'.format(match)) ''' run: Found: 'xy' Found: 'xyy' Found: 'xy' Found: 'xyy' '''