我有类似的东西:
"1111Austria9999Salzburg (SZG)Vienna (VIE)1111Bosnia-Herzegovina9999Sarajevo (SJJ)1111Bulgaria9999Bourgas (BOJ)Varna (VAR)"
我想提取
Salzburg (SZG), Sarajevo (SJJ), Bourgas (BOJ), Varna (VAR)
答案 0 :(得分:1)
import re
sentence = "1111Austria9999Salzburg (SZG)Vienna (VIE)1111Bosnia-Herzegovina9999Sarajevo (SJJ)1111Bulgaria9999Bourgas (BOJ)Varna (VAR)"
regs = re.findall(r'[A-z]+\s\([A-Z]{3}\)', sentence)
print(regs)
这来自我在评论中的逻辑。