我试图从number
旁边的值下面的文本和介于两者之间的文本中提取.
Text:
The conditions are: number 1, the patient is allergic to dust, number next, the patient has bronchitis, number 4, The patient heart rate is high.
从本文中,我想提取以下值:
1, the patient is allergic to dust,
next, the patient has bronchitis,
4, The patient heart rate is high
我有一个模式,可以得到number
和句子第一个单词旁边的值:
(numbers? (\d+|next)[,.]?\s?(\w+))
这是使用re.findall
的结果
[('number 1, the', '1', 'the'),
('number next, the', 'next', 'the'),
('number 4, The', '4', 'The')]
如你所见,使用组,我可以从文本中提取数字或next
值.但我无法提取整个句子.