Read specific Sender from multiple entries in txt file

Hi,

(1) My txt file looks like this:

image

For a known unique number (in green) I need to get a sender name (in blue), which can be in 1-3 lines.

(2) At the beginning of this txt file there is a table with all specific unique numbers in a file. I would like to delete this table → i.e. delete all text in a file before first occurence of text “Post:”.

Thx for any suggestions.

Kind regards,
Vanja

Hello!

For the first one, One of the possible solutions is to regex the text between the Unique number and the word Receiver:

System.Text.RegularExpressions.Regex.Match(sFile,"(?<=UNIQUE_NUMBER)([\S\s]*)(?=Reciever:)").ToString

Then, use a regex to get all text after Sender: (In the result variable from above)

(?<=Sender:).*

For the second one, use the Same Regex to get all text after Sender, but change the word to “Post:”

Use these functions in the assign, as this example:

Regards,
Lucas

1 Like

@Lucas_Capalbo great thx! I like your way of thinking.

For the second. The table is before the text in picture above.
So, now I am thinking, I might replace substring of all text from 0 to “Post:” with blank.

Thanks a lot!
Vanja

1 Like

Hi @Lucas_Capalbo

System.Text.RegularExpressions.Regex.Match(sFile,“(?<=UNIQUE_NUMBER)([\S\s]*)(?=Reciever:)”).ToString

is not working :frowning:

There are many “Receiver:” in the text. Might be the reason?

Yes, sorry

Please, Try this one instead:
(?<=UNIQUE_NUMBER)([\S\s]*?)(?=Reciever:)

I’ve just added ‘?’ inside ([\S\s]*)

1 Like

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