fork download
  1. # your code goes here
  2. import re
  3. asx = 'cat'
  4. string='ffcathsvncathcatsssc'
  5.  
  6. print("findall output all result string:", re.findall(asx, string))
  7.  
  8. for i in re.finditer(asx, string):
  9. print("finditer output match object:", i)
Success #stdin #stdout 0.03s 27728KB
stdin
Standard input is empty
stdout
findall output all result string: ['cat', 'cat', 'cat']
finditer output match object: <_sre.SRE_Match object; span=(2, 5), match='cat'>
finditer output match object: <_sre.SRE_Match object; span=(9, 12), match='cat'>
finditer output match object: <_sre.SRE_Match object; span=(13, 16), match='cat'>