Answer the question
In order to leave comments, you need to log in
Why doesn't it work the way it should?
trans_compile2 = re.compile('[(.+)|(.+)]')
res2 = trans_compile2.findall('[id501053137|Александра]')
['|']
Answer the question
In order to leave comments, you need to log in
Everything just works as it should.
[ ] and | have a special meaning in the regex. If you need exactly such characters, you need to escape them with\
re.compile('\[(.+)\|(.+)\]')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question