Get string between two characters c#

Hello All,

I am using this code to extract string between two topics…

text.str = dataText.ToString.Substring(dataText.IndexOf(“heading1”) + “heading1”.Length, dataText.IndexOf(“heading2”) - dataText.IndexOf(“heading1”) + “”.Length)

but i am getting extra text in the bottom …so can any one help me out this…

Thanks,
Suresh.

Hi @suresh_kumar4

Try this regex to get the text between two text.

regexPattern = (?<=Heading 1)(.*\n)+(?=Heading 2)

I’m attaching the workflow for your reference. ExtractStringBetweenTwoStrings.zip (14.0 KB)

Hi @suresh_kumar4

You can use this article for your reference. :smiley:

cheers :smiley:

Happy learning :smiley:

@suresh_kumar4,

Check this workflow, it may help you extract string between two strings.
StringBetween2Words.xaml (8.2 KB)