Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中从文本数据中提取数字和相邻单词_Python_Regex_Data Extraction - Fatal编程技术网

在python中从文本数据中提取数字和相邻单词

在python中从文本数据中提取数字和相邻单词,python,regex,data-extraction,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

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

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

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