Uipath Regex not taking data if it is 1 decimal point

Hi Everyone, I have this issue. The regex I run (?<=NOx (g/kWh):\s+)\d+.\d{2} is only returning data that has more than 2 decimal point (for exp =10.97029703) . If the data has 1 decimal point it will not extract (for exp = 10.4. Same goes for (?<=SFOC (g/kWh) (MDO):\s+)\d+.\d{2}

This is the regex in UiPath System.Text.RegularExpressions.Regex.Match(CurrentConsumer.Item(“Parameters”).ToString,“(?<=NOx (g/kWh):\s+)\d+.\d{2}”).ToString

System.Text.RegularExpressions.Regex.Match(CurrentConsumer.Item(“Parameters”).ToString,“(?<=SFOC (g/kWh) (MDO):\s+)\d+.\d{2}”).ToString

This is extracted data table in excel
"Engine Type: Medium Speed Diesel (MSD, 300 < rpm ≤ 900)
Fuel Types: HFO, LFO, MDO/MGO
NOx (g/kWh): 10.97029703
MCR RPM: 720
SFOC (g/kWh) (MDO): 198.7866787
ISO Correction Exponent M: 0.7
ISO Correction Exponent N: 1.2
ISO: 1
Mechanical Efficiency: 0.85
"

For me I just need to extract the everything from SFOC (g/kWh) (MDO): 198.7866787 and NOx (g/kWh): 10.97029703, since the extraction is not stable for 2 decimal point. How do I do this ya?

@Irfan_Musa

use the below regex expression in Find Matching Pattern activity and then use the for each

(?<=\):\s+)\d+.\d+

or use the below syntax in assign activity and use the for each

System.Text.RegularExpressions.Regex.Matches(input,"((?<=\):\s+)\d+.\d+)")

Hope it helps!!

1 Like

Hi @Irfan_Musa

(?<=NOx \(g/kWh\):\s+)\d+(\.\d+)?

(?<=SFOC \(g/kWh\) \(MDO\):\s+)\d+(\.\d+)?

Regards,

@Irfan_Musa

Use find matching pattern activity

Thank you very much, yes it works.

@Irfan_Musa

Your Welcome

Happy Automation!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.