【发布时间】:2021-01-09 11:38:36
【问题描述】:
我尝试了下面的 ff 正则表达式,但它似乎不起作用。我想提取 F. Prepaids 和 G. Initial Escrow Payment 之间的数据,并得到下面的 ff 示例结果。谢谢。
#我的正则表达式
(?<=F. Prepaids)[\S\s]*?(?= G. Initial Escrow Payment)
#字符串
F. Prepaids $887.01
01 Homeowner's Insurance Premium ( 12 mo.) toAmerican Family $893.00
Insura
02 Mortgage Insurance Premium ( mo.)
03 Prepaid Interest ($5.99 per day from 10/02/2020 to 10/01/2020) -$5.99
04 Property Taxes ( mo.)
05
06
07
08
G. Initial Escrow Payment at Closing $3,776.11
如果我得到介于两者之间的数据,我还想要一个正则表达式来获得 ff 结果,其中其他数据包括基于上述字符串的新行。
Homeowner's Insurance Premium ( 12 mo.) to American Family Insura
Mortgage Insurance Premium ( mo.)
Prepaid Interest ($5.99 per day from 10/02/2020 to 10/01/2020)
Property Taxes ( mo.)
对这个有什么想法吗?谢谢。
【问题讨论】:
-
要获取中间的内容,请省略 G 之前的空格。
-
什么意思?
-
G前面的lookahead中有一个空格。见regex101.com/r/n6PgvI/1
-
使用
(?<=F. Prepaids)[\S\s]*?(?=G. Initial Escrow Payment)