fork download
  1. import re
  2. rx = r'\(([^)]+)\)'
  3. string = """Name Multiple Words Zero Row* (78.59/0) Name Multiple Words2* (96/24.56) Name Multiple Words3* (0/32.45) Name Multiple Words4* (96/12.58) Name Multiple Words5* (96/0) Name Multiple Words Zero Row6* (0) Name Multiple Words7* (96/95.57) Name Multiple Words Zero Row8* (0) Name Multiple Words9*"""
  4.  
  5. for match in re.finditer(rx, string):
  6. parts = match.group(1).split('/')
  7. First_Num = parts[0]
  8. try:
  9. Seg_Length = parts[1]
  10. except IndexError:
  11. Seg_Length = None
  12.  
  13. print "First_Num, Seg_Length: ", First_Num, Seg_Length
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
First_Num, Seg_Length:  78.59 0
First_Num, Seg_Length:  96 24.56
First_Num, Seg_Length:  0 32.45
First_Num, Seg_Length:  96 12.58
First_Num, Seg_Length:  96 0
First_Num, Seg_Length:  0 None
First_Num, Seg_Length:  96 95.57
First_Num, Seg_Length:  0 None