次の文字列があるとします。
string = "** Hunger is the physical sensation of desiring food.
<br> Your Hunger Level: Very Hungery<br> Food You Crave: Tomato<br/><br/>"
「あなたの空腹」と「トマト」を抽出できるようになりたいです。どのような特殊文字が挿入されても、"Your Hunger Level:" と "Food You Crave" は常に一定であることがわかっています。
"Your Hunger Level:" could be: "Very Hungry", "Hungry", "Not So Hungry"
"Food You Crave:" could be: "Tomato", "Rice and Beans", "Corn Soup"
これを一致させるために正規表現を使用するにはどうすればよいですか? 私は次のことを試しましたが、運がありません...
m = re.match('(.*)([ \t]+)?Your Hunger Level:([ \t]+)?(?P<hungerlevel>.*)(.*)Food You Crave:([ \t]+)?(?P<foodcraving>.*).*', string)
注: 文字列には、以下に示す多くのエスケープ文字が含まれているようです。
string = "** Hunger is the physical sensation of desiring food. <br>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tYour Hunger Level:
Very Hungry \n\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\tFood You Crave: Tomato \n\t\t\t\t\t\t</br>"