fork download
  1. import re
  2. rx = r'(\w+\([\d/]*\))|(\()|\)'
  3. def repl(m):
  4. if m.group(1):
  5. return m.group(1)
  6. elif m.group(2):
  7. return ", "
  8. else:
  9. return ""
  10.  
  11. s='모질상태불량(피부상태불량, 심하게 야윔), 치석심함, 양측 수정체 백탁, 좌측 화농성 눈곱심함(7/22), 코로나음성(활력저하)'
  12. print(re.sub(rx, repl, s))
Success #stdin #stdout 0.01s 27712KB
stdin
Standard input is empty
stdout
모질상태불량, 피부상태불량, 심하게 야윔, 치석심함, 양측 수정체 백탁, 좌측 화농성 눈곱심함(7/22), 코로나음성, 활력저하