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


How about the following expression?



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

(In case your string has multiple lines)


1 Like