If you want to use the regular expression, you should use the regular expression as follows:
import re tmp_string = ''' en/lemon_peel/n/, ca/llimona/n/, ''' reg = re.search('/([^/,]*)/',tmp_string) result = reg.group(1)
In your case, you will find all characters that are not '/'.
Or you can use the split function instead of re :
tmp_string.split('/')[1]
source share