I have the following text and want to extract '- あらたなるきぼう'
which is between '('
and the Japanese character '、'
st1='『スター・ウォーズ エピソード4/新たなる希望』( - あらたなるきぼう、Star Wars Episode IV: A New Hope)'
I used two regex methods to extract what I wanted but neither of them worked.
# -*- coding: utf-8 -*-
import re
st1='『スター・ウォーズ エピソード4/新たなる希望』( - あらたなるきぼう、Sta r Wars Episode IV: A New Hope)'
m1 = re.search('\(([^、]*).*、.*\)',st1)
m2 = re.search('\((.*?)、.+?\)',st1).group(1)
Any idea what I am doing wrong?
Of course I could use the split method, first on '、'
then on '('
. First of all it is ugly and not robust and second for some reason it does not split by '('
:
st1.split('、')[0].split('(')`