Get certain lines from string

Hi, i have output from Read PDF text.

from this long string, i would only want to get the lines that is starting from word ‘Item’
and ends with line that has word ‘Total Amount’. The amount of lines are not fixed. Basically its a half table if you would say. I attached the sample string also.

Have tried regex but not able to get the correct lines.

Best if i can get only the row items from the table in the string.

Please advice on the best way.
invoice 1 with format.txt (2.1 KB)

Hi @syezids

How about this Regular expression?

System.Text.RegularExpressions.Regex.Match(YourString,"(?s)Item(.*?)Total Amount").Tostring

Regards
Gokul

1 Like

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.Match(strData,"(?<=\n)\s+Item[\s\S]+?Total Amount:.*").Value

Sample20230309-3L.zip (2.7 KB)

Regards,

Hi @syezids ,

Could you try with the below Regex Expression :

(?=.*Item)[\s\S]+(?<=Total Amount:).*

thanks all for the fast solutions! all 3 works!

1 Like

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