How to Extract Report from the text File by Using RegEx

Hi every one,
I have a Text File Which contains Multiple reports In it. But I need to fetch only
“IVR CARD ACTIVATION REPORT” I tried to Extract the report by using RegEx . but I couldn’t able to get the Solution. Am trying to get the Solution from 2 day.

I have attached the Text File. Please some one can go through the file and help Me.
Three “IVR CARD ACTIVATION REPORT” are there in the above File.

Thanks in advance

Not the smoothest pattern but this would work


Be sure to use Singleline option when validating your regex

Hello @nitesh.s ,

Providing an example of expected result might help to answer to this kind of questions.

I hope you provided fake data. Otherwise, you should delete the file and the screenshot.

  1. At first glance, you might be able to split the file into document page on Form Feed (vbFormFeed)
  2. The page you’re interested in begins by space then "IVR CARD ACTIVATION REPORT"
  3. If you want to keep only the table lines from these pages, you’re lucky as the formatting seems consistent with obvious pattern.

Consequently, my advice is to match the pages you need, given String input as you raw text:

String pattern = "\s*(IVR CARD ACTIVATION REPORT[\s\S]+?)\s*?\f"
MatchCollection pages = System.Text.RegularExpressions.Regex.Matches(input, pattern)

Then you parse each page value to get what you need.

For Each page As Match in pages
    String raw = page.Value
    ' Do what you need to do
Next page

Edit: If you want to play safe, you might prefer a Regex.Split on pattern "\s*?\f+\s*" then filter the result on the title then parse the remaining strings. The anwer is still valid for the file provided but keep that in mind.

1 Like