Reputation: 41
I have this string:
Frage\tf, -n 1. въпрос; питане; 2. проблем; eine dumme, peinliche ~ глупав, неудобен въпрос; jmdm. eine ~ stellen задавам въпрос (някому);
and I want to get just the beginning of it - till the first ";", remove the \t and the number with a comma(1.), and after that save it in a new list. It seems like an easy problem but I got stuck on it, so can someone help?
Upvotes: 0
Views: 71
Reputation: 2936
Here's something I've tried:
import re
text = r"Frage\tf, -n 1. въпрос; питане; 2. проблем; eine dumme, peinliche ~ глупав, неудобен въпрос; jmdm. eine ~ stellen задавам въпрос (някому);"
pattern = "^(.*?);"
x = re.search(pattern, text)
print(re.sub(r"\d.", "", x.group(1).replace(r"\t", "")))
Upvotes: 1