Regex help - extracting part of a string

Hello - I am trying to extract part of the string below using regex but I am having trouble with it. Can anyone help me out with this? I am getting the string from reading a PDF and outputting the content as a string. The problem is the figures below can change and may or may not include $

The string is:

IN05 33.14 Based On CAD 984.74
IN06 $ 951.60 13.00% HST CAD 6.24

I am trying to extract using the same regex code…

IN05 33.14
IN06 $ 951.60

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"^\w+\s*\$?\s*[.\d]+").Value

or

mc = System.Text.RegularExpressions.Regex.Matches(yourString,"^\w+\s*\$?\s*[.\d]+",System.Text.RegularExpressions.RegexOptions.Multiline)

(In case your string has multiple lines)

Regards,

1 Like