Extract String from Text file


I want to extract specific string from a text file.
I have tried 2 methods but struck on same point:

  1. I have read the text file and saved data in form of list of string type.
  2. I have read text file and saved data in a single string variable using ReadLine.
    My problem is how to get index of specific words from string or list so that I can use substring method to get substring containing data between specific words.
    I am using IndexOf to get index of that word but everytime I am getting 0 as result.
    please help.


HI @TwinkleTyagi,

Can you provide the sample input and your expected output.

Regards, Arivu :slight_smile:


Hi @TwinkleTyagi,

Try something like this in Invoke Code activity,

Dim St As String = “string pulled from the text file using reader which has key : text I want to keep - end of my string”
Dim pFrom As Integer = St.IndexOf("key : ") + "key : “.Length
Dim pTo As Integer = St.LastIndexOf(” - ")
Dim result As String = St.Substring(pFrom, pTo - pFrom)

Note: “key :” and " -" are the two strings of the string’s starting and end which we need to search and get.
we can return the result to the workflow and can use it


Like if a text file contains text -
"Quick brown

fox jumps right

over the little

lazy dog."

And I want to get the text between words “fox” and “lazy”.

Then the output should be -

"fox jumps right

over the little"


HI @TwinkleTyagi,

Refer this post

Regards, Arivu :slight_smile:


Can you please provide me xaml file.


Hello @TwinkleTyagi

Attaching a sample .xaml file for your reference. I have used invoke code activity which accepts “from” and “to” strings as input arguments. You can change them and check as per your need.

Let me know if this helps
GetTextBetweenStrings.xaml (6.2 KB)


Hi @TwinkleTyagi,

check the workflow,

ReadTextFile.xaml (7.1 KB)


@TwinkleTyagi Check below file

Between.zip (1.8 KB)


Thank you Manju Nath, it worked.

and thank you everyone for your valuable information, I learned a lot.