艺术家 - 头衔(某事)
的示例:
"ellie goulding - good gracious (the chainsmokers remix)"
"the xx - you got the love (florence and the machine cover)"
"neneh cherry - everything (loco dice remix)"
"my chemical romance - famous last words (video)"
我一直在尝试,但我们找不到合适的正则表达式。
regex = "[A-Za-z0-9\s]+[\-]{1}[A-Za-z0-9\s]+[\(]{1}[\s]*[A-Za-z0-9\s]*[\)]{1}"
请帮忙!
答案 0 :(得分:1)
>>> import re
>>> songstring = 'ellie goulding - good gracious (the chainsmokers remix)'
>>> re.match(r'(.*?) - (.*?) (\(.*?\))', songstring).groups()
('ellie goulding', 'good gracious', '(the chainsmokers remix)')
答案 1 :(得分:1)
我愿意
regex = r"^[^\-]*-[^\(]*\([^\)]*\)$"