Answer the question
In order to leave comments, you need to log in
How to use regular expressions to select 2 or more words?
There is a regular expression - %\w+%
It is from the line Monday:\n1.%Geography Math%(8:30-9:15)
Doesn't select anything, how can I make it select all of them regardless of the number of words inside %%?
Answer the question
In order to leave comments, you need to log in
In [13]: list(re.findall('%(\w+ *\w+)%', '\n1.%География Математика%(8:30-9:15)'))
Out[13]: ['География Математика']
In [14]: list(re.findall('%(\w+ *\w+)%', '\n1.%ГеографияМатематика%(8:30-9:15)'))
Out[14]: ['ГеографияМатематика']
In [15]: list(re.findall('%(.+)%', '\n1.%ГеографияМатематика%(8:30-9:15)'))
Out[15]: ['ГеографияМатематика']
In [16]: list(re.findall('%(.+)%', '\n1.%География Математика%(8:30-9:15)'))
Out[16]: ['География Математика']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question