How to extract data from txt file using regex

Hi @vinjam_likitha ,

We could also do the below Operation by two Steps :

  1. First we would have to Get the Data between two Keywords, so we use the following :
keysText = System.Text.RegularExpressions.Regex.Match(textData,"(?<=serial open request)(.*\n)*(?=DCU E72)",RegexOptions.IgnoreCase).Value.ToString.Trim

where keysText is a String variable, which will have the data between the two keywords, textData will be your Input Data

image

  1. Next, as we need the each line separately, we can use Split based on NewLine as below :
KeysList = Regex.Split(keysText,"\n")

where KeysList is a variable of Type Array of String.

This variable will contain each keys as one line i.e as one item in the array
image