Find a specific string between two specific words in Python3

  list, python-3.x, re, search, string

I want to separate the stem and options of a multiple choice question.

for example:

import re
newstr = "1 which season do you like best after looking at these pictures A spring B summer C autumn D winter E none"
result = re.search('1(.*)A', newstr)
print(result)

but the output result is not my expected result.

<re.Match object; span=(0, 65), match='1 which season do you like best after looking at >

The result I hope to get is:

str1 = 'which season do you like best after looking at these pictures'
str2 = 'spring summer autumn winter none'

How can I achieve it?

thanks

Source: Python-3x Questions

LEAVE A COMMENT