fork download
  1. import re
  2.  
  3. regex = r"\"\w+\/\w+(?: \w+\/\w+)*\""
  4. test_str = ("\"a/b b/c\"\n"
  5. "\"a/b python/Java\"")
  6. matches = re.findall(regex, test_str, re.MULTILINE)
  7.  
  8. for match in matches:
  9. res = map(lambda s: s.replace("/", "") if len(s) == 3 else s, match.strip("\"").split())
  10. print('"{0}"'.format(" ".join(res)))
  11.  
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
"ab bc"
"ab python/Java"