Regex get next line


I have couple questions about regex:

Net Cash

I want to get 5/7/2018. I tried (?<=Net Cash)((\n.*){1}) which gives me this:

how can I start at the line 5/7/2018 and skip all the white space after Net Cash?
Is there a better way to get the data in the next line after finding the match?

Buyer Code:
703-027 01 abc 5523
703-027 01 cde 1423
703-027 01 efg 63.33
703-027 01 aaa 45.70
Version: 10.1

I need to get

703-027 01 abc 5523
703-027 01 cde 1423
703-027 01 efg 63.33
703-027 01 aaa 45.70

I was thinking (?<=(Code$))((\n).*)
but it gives me the white space behind “Code” and 703-027 01 abc 5523 only
It does not always start with 703-027 01, that’s why I need to use Code to find the lines.

  1. I am using to test, could you please briefly explain the difference between Full Match, Group 1, Group 2?

Thanks a lot!


Hi @lavint

See attached xaml example for reference. It does what you specified in the original post: (2.3 KB)

Knowing how it goes, you will probably have to tune it a bit.
But the gist of the solution is to first split your string using .Split method and only then apply your Regex (if needed).

As to the questions, this code:
produces those groups because anything you put between () is treated as a group. Try removing those groups like this:
to see the difference and that they are gone.

Let me know if you have any questions. The code in my example might seem cryptic, but really isn’t and I would be happy to explain more if needed :slight_smile:

I am trying to capture a word below a specific word, in this case i’m trying to capture a word below Billed in the next line.

I tried this expression: (?<=Billed\s)(|\n)([^.]+) it doesn’t give me what i need. i want to capture only the name Rahul Jignesh which is dynamic.


@Khehla_Malakoane Welcome to the forum!

Test with this pattern:


@Khehla_Malakoane - Since I worked on this PDF very recently , I can supply with the xaml.

Here it is Main.xaml (18.8 KB). Output file Invoice.xlsx (8.2 KB)

If you get a any missing activity (Autofit Columns), Please use BalaReva.Excel.Activities.

Please mark this as solution, if it solves your query.

1 Like

@prasath17 This solved my query, Thank you :ok_hand:

@ptrobot worked :ok_hand:

1 Like

@Khehla_Malakoane - Please mark as Solution…