从python的文本数据中提取数字和附近的单词

时间:2019-05-08 17:33:45

标签: python regex data-extraction

我在数据框的一列中有文本字符串数据

Text Column
The doctor has advised the patient to pay $200 for the treatment
Patient submitted the $200 operation fee but not the admit fee  $100

如何从上方提取数字以及该数字前后的单词并将其存储在单独的变量中

Expected Results
Var1                 Var2     
pay $200 for
the $200 operation   fee $100

1 个答案:

答案 0 :(得分:0)

([a-zA-Z]+) *?\$?([0-9]+) ?([a-zA-Z]*)

Try it out online