How to ignore whitespace in Regex Expression

I have this pdf file that I get my text, using read pdf txt. In that string, I am trying to get this particular line
I managed to get the “BUY USD” by using buy [A-Z]{3}. But I also need to get the number on the right side but it has too many spaces and the regex builder won’t even recognize it, even if I put a Digit(\d)


Can you try the following pattern?

[A-Z]{3} [A-Z]{3}\s+[\d.,]+

Expression :

System.Text.RegularExpressions.Regex.Match(yourString,"[A-Z]{3} [A-Z]{3}\s+[\d.,]+").Value


Hi @Shinjid

Please try this,

(?<=BUY USD)[\s\d]*

It will get both space and number after buy usd ,

If the output is strResult

Use strResult.tostring.trim to remove all the spaces


Thank you! It worked.

1 Like

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