Regex to extract data in between string

前端 未结 1 1131
抹茶落季
抹茶落季 2021-01-23 12:38

Ive tried the ff regex below but it does not seem to work. I wanted to extract data between F. Prepaids and G. Initial Escrow Payment and get the ff sample result below. Thanks.

相关标签:
1条回答
  • 2021-01-23 13:04

    You may use

    (?m)(?<=F\. Prepaids[\s\S]*?^\d+ )[^\r\n]+(?:\r?\n[^\n\d][^\r\n]*)?(?=[\s\S]*?\nG\. Initial Escrow Payment)
    

    See the regex demo

    Details

    • (?m) - multiline mode on
    • (?<=F\. Prepaids[\s\S]*?^\d+ ) - match a location immediately preceded with F. Prepaids, then any zero or more chars as few as possible, then 1+ digits at the start of a line and then a space
    • [^\r\n]+ - any one or more chars other than CR and LF and
    • (?:\r?\n[^\n\d][^\r\n]*)* - zero or more sequences of CRLF or LF ending, any non-digit and non-newline char and then any zero or more chars other than a newline and carriage return
    • (?=[\s\S]*?\nG\. Initial Escrow Payment) - the current location must be followed with
      • [\s\S]*? - any zero or more chars as few as possible
      • \n - a newline
      • G\. Initial Escrow Payment - a G. Initial Escrow Payment text.
    0 讨论(0)
提交回复
热议问题