How to get text between heading1 and heading2

Hello,

can any one help me how to get text between heading1 and heading2. in text file or pdf file…

image

Thanks,
Suresh.

1 Like

Fine if this string is placed in a text file
—use READ TEXT FILE activity and get the output with a variable of type string named str_input
—now use a ASSIGN activity like this
Str_output = System.Text.RegularExpressions.Regex.Match(str_input,”(?<=Heading1).*(?=Heading2)”).ToString

Cheers @suresh_kumar4

2 Likes

Thanks @Palaniyappan Let me try this.

1 Like

Sure
Cheers @suresh_kumar4

Hi @suresh_kumar4

Try this regex to get the text between two text.

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

Hi,

i am getting like this…

@suresh_kumar4
Can you share your workflow with input file?

ExtractStringBetweenTwoStrings.xaml (5.3 KB)

data.txt (116 Bytes)

str.Split({“Heading 1”+Environment.NewLine, Environment.NewLine+“Heading2”},StringSplitOptions.None)(0)

if i use the above expression. i am getting empty…message box…

Please do needful.

Regards,
Suresh.

1 Like

here you got with a xaml
hope this would help you
extract.zip (9.4 KB)
Cheers @suresh_kumar4

sorry getting error while opening the file…

1 Like

fine
this was the expression used
test.ToString.Substring(test.IndexOf(“Heading1”)+“Heading1”.Length,test.IndexOf(“Heading2”)-“Heading2”.length).ToString

Cheers @suresh_kumar4

1 Like

Thanks a lot @Palaniyappan !!! …

But here my 2nd heading also coming while extracting… so can you help me on this final issue…
image
like this i am getting…

i need only this part…

image

Thanks,
Suresh.

Hi
hmm…
actually it gave that output only
image
Cheers @suresh_kumar4

can you send me the code…

yah sure
extract.zip (9.4 KB)

Cheers @suresh_kumar4

sorry for the inconvinience , pls send me the code alone i am not able to open this file…

Fine
here you go

ExtractStringBetweenTwoStrings.xaml (5.5 KB)
Cheers @suresh_kumar4

still i am getting that extra text, any how thanks a lot…