fork download
  1. import re
  2.  
  3. string = 'abcdcdc'
  4. sub_string = 'cdc'
  5.  
  6. count = len(re.findall('(?=%s)' % sub_string, string))
  7.  
  8. print(count)
Success #stdin #stdout 0.02s 28376KB
stdin
Standard input is empty
stdout
2