fork(1) download
  1. import re
  2.  
  3. #original string
  4. text = "The dog walked (ABC in the park"
  5. text = re.sub(r'(\([A-Z]+(?!\))\b)', r"\1)", text)
  6. print(text)
Success #stdin #stdout 0.03s 9516KB
stdin
Standard input is empty
stdout
The dog walked (ABC) in the park