Extract repeated string from text file

Hi all,
I am trying to extract some data in a text file. I tried to use my data.Split({“special”,”good”},StringSplitOptions.None) to extract data between words special and good. However, these two words appear many times in the text file and I only want to extract the latest data. My logic is to count how many times they appear and only choose the last time to extract, but I dun know how to write it…

Anyone can help!

Many thanks.

Hi @raymondhui,

Use regular expression
write pattern for that & get the data

Hi @varunk

Pattern = “special”?
But I dun want to get all of the result but only the last one.

Hi @raymondhui,

You need to write pattern according to groups,then latest means from file starting or ending
According to that you can take that group

Hi @varunk

I am not familiar with regular expression, especially patterns, would you mind share more about it?

Many thanks


Simply take the second last item in your array.


in matches activity you will get an IEnumerable of Matches.
in that you can use Variable.LastOrDefault

Hi @Vijay_Tulsalkar

Thx bro but actually I need to extract data between first one and last one. Would u like to show me the steps?



can you explain with an example. can you share the TEXT here and the end result required?


Sorry mate can’t upload the text file right now and only can upload the image for your reference.

Attached you can find Identifier Report EL-888 and last pages TRANSATION TOTAL RECORD. Supposed this one is the result and these data are captured from a raw text files.

Many thanks

Have your tried this?


Hi @HalmiNordin
Yes but it’s not returning value I want

What value do you actually want?

Would upload txt file later thx mate


I’m still confused, as per my understanding just try out this approach.

  1. Split with special then take the lastordefault index of it and store in variable.
  2. then split the variable with good and take the first index value.

the code might look something like this