Reguler exprestion

Hello

I can find Subtotal using regulars expression. In input string there have two subtotal but I have only one output as mention in below.

Input string is:

3,541.600 Total MSI
Price/MSI 5.32000 Subtotal 7,137.31

Slitting No Charge 0.00

Subtotal 7,534.82
Shipping Charges 238.16

Total Due 7,512.98 USD
Did you know that you can pay your invoices online?

Output is : 7,534.82

what is the regulars expression?

Thanks
Minal

Hi @minal.patil ,

Can you try this,

System.Text.RegularExpressions.Regex.Matches(str,“((?<=Subtotal).*)”)(1).ToString

Thanks!

Hi,

FYI, another approach:

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Subtotal\s*)[.,\d]+",System.Text.RegularExpressions.RegexOptions.RightToLeft).Value

Regards,

Hi @minal.patil ,

Maybe An Alternate Regex Expression :

^Subtotal\s*([.,\d]+)

Expression to use :

System.Text.RegularExpressions.Regex.Match(InputString,"^Subtotal\s*([.,\d]+)",RegexOptions.IgnoreCase).Groups(1).Value.ToString

The above is also assuming that the Subtotal Label you want is always at the start of the line and there are no other Subtotals at the start of the line.

Let us know if it doesn’t work.

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