Hello I have the following texts where I need to capture the last number 899.48, 238.84, 5111.87
Wholesale Market Service Charge reflecting electricity consumed before and 321,242.175 kWh at $0.0039 per kWh 899.48
Wholesale Market Service Charge or close your Toronto Hydro services is online. 711,242.175 kWh at $0.0039 per kWh 238.84
Wholesale Market Service Charge Are you moving? The fastest way to set up tra 601,242.175 kWh at $0.0039 per kWh 5,111.87
basically anything could be in between “Wholesale Market Service Charge” and the number of kWh (the bold part), the number of kwh will always be at the beginning of the second line. I need to match this way because there are other instances of this format: 711,242.175 kWh at $0.0039 per kWh 238.84 and I need to capture only the Wholesale Market Service Charge.
the regex I have now isn’t working:
(?<=Wholesale Market Service Charge )(?:.*\r?\n[\d,.]+\skWh\sat\s$[\d,.]+\sper\skWh )([\d,.]+)
Thanks so much @ppr, sorry I meant to capture the last number in the second line. would you please use the below for testing instead?
“321,242.175 kWh at $0.0039 per kWh 899.48”
“711,242.175 kWh at $0.0039 per kWh 238.84”
“601,242.175 kWh at $0.0039 per kWh 5,111.87”
these parts start in the second line…
Wholesale Market Service Charge reflecting electricity consumed before and 321,242.175 kWh at $0.0039 per kWh 899.48
Wholesale Market Service Charge or close your Toronto Hydro services is online. 711,242.175 kWh at $0.0039 per kWh 238.84
Wholesale Market Service Charge Are you moving? The fastest way to set up tra 601,242.175 kWh at $0.0039 per kWh 5,111.87
I have amended the Regex Pattern as I missed a couple characters Preview link. (?<=Wholesale Market Service Charge.*\n*)[\d,\.]+(?=[\r\n]|$)
Note: There was no line return in your sample when copied to Regex101.com etc. So I wasn’t sure if it was actually there or not. I copied your sample directly and built from that.
As per @ppr’s reply. Please keep it mind if you need a second pattern in the future