fork(1) download
  1. import re
  2. strs= ['AbcS:sdaf', 'AbcSsdaf']
  3. pattern= re.compile(r'([^:]*):')
  4. for s in strs:
  5. m = re.match(pattern, s)
  6. if m:
  7. print(m.group(1))
  8. else:
  9. print(m)
  10.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
AbcS
None