fork(1) download
  1. import re
  2. strs = [' MACHINE: \nldnmdsbatchxl01','MACHINE: p2prog06', 'MACHINE: p1prog\n07']
  3. for s in strs:
  4. print(s)
  5. m=re.search(r'\bMACHINE:\s*(.*(?:\s*^\d+)?)', s, re.M)
  6. if m:
  7. print("Result: " + m.group(1).replace("\n", "").replace("\r", ""))
  8. print("-----------------")
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
 MACHINE: 
ldnmdsbatchxl01
Result: ldnmdsbatchxl01
-----------------
MACHINE: p2prog06
Result: p2prog06
-----------------
MACHINE: p1prog
07
Result: p1prog07
-----------------