re = /(?<=\(INR\))(.|\n)*(?=Due Date)/m
str = 'Format : ExpoHub
123456789
expohub street
ABC
123456
India
Billed To Date of Issue Invoice Number Amount Due (INR)
Nagesh Reddy. 22/04/2020 873101. Rs.26,178.00
Due Date
22/05/2020
Description Rate Qty Line Total
Shared Hosting Rs.25,878.00 1 Rs.25,878.00
LateFee Rs.300.00 1 Rs.300.00
Rs.0.00 1 Rs.0.00
Subtotal 26,178.00
Tax 0.00
Total
Amount Paid
26,178.00
0.00
Amount Due (INR) Rs.26,178.00'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html