I want to create a regex pattern to get stuff between two words.
Start:
Apple
Cat
Ball
End:
I want to get the data between Start: and End:
I was able to find this data using C#:
region Get Required Field Data
public static List<string> GetRequiredData(string[] lines, string StartPos, string EndPos)
{
List<String> RequiredField = new List<String>();
bool hit = false;
foreach (var line in lines)
{
if (line == EndPos)
{
hit = false;
}
else if (hit == true)
{
if (line != "\t"||line=="")
{
RequiredField.Add(line);
}
}
else if (line == StartPos)
{
hit = true;
}
}
return RequiredField;
}
#endregion Get Required Field Data
But i think using regex for the same purpose will be cool. I tried (?<=Start:)(.*)(?=End:) but it is not working.Plus i also want to remove any line in between with no text.
I will really appreciate any help. Thank You,