How to detect desired collection of words scattered in multiple lines

Hi Folks,
I have a automation problem. I am reading PDF file and the I am getting the data in this form.

Notice Of Change Of 6232452-OC1920580
Address For Service- GRIGORYEV
Instrument
Notice Of Change Of 6201481-SC1511463
Address For Service- NACCARATO
Instrument
Notice Of Change Of 6325041-PR3201180
Address For Service- SYMONS
Instrument
Notice Of Change Of 6344395-AT4948713
Address For Service- PARTOZA
Instrument

I want data in this form:

Notice Of Change of Address For Service-Instrument 6232452-OC1920580 GRIGORYEV
Notice Of Change of Address For Service-Instrument 6201481-SC1511463 NACCARATO
Notice Of Change of Address For Service-Instrument 6325041-PR3201180 SYMONS
Notice Of Change of Address For Service-Instrument 6344395-AT4948713 PARTOZA

How do I achieve this? Please provide your thoughts that how we can manipulate the string to get the desired results! Thanks.

@Umer_Shahid

Use split and then combine…as you already know the static text…just split with that and then join back

  1. Str.Split({"Notice Of Change Of","Address For Service-","Instrument"},Stringsplitoptions.RemoveEmptyEntries) this give you array of strings like below

{6232452-OC1920580,GRIGORYEV,6201481-SC1511463,NACCARATO……}

If you observe what you need is joining the first and second strings…so basically get the even group and odd group of strings and join them…

Hope this idea gives you a way.happy to help if you are stuck

Cheers

@Anil_G see three separate lines means that they are different strings. Your solution is way when the entire thing is a string.

@Umer_Shahid

You can wither join them together and use it…if they are separate even more good…for eqch line you get …you get either of them…when you get line with ‘notice of change’ then start building your string …when you get ‘address for service’ append the string and when you get instrument it means next string will start so your first is completed

Cheers

Hello @Umer_Shahid

I’ve made a probable solution for your problem. Just assign your string data into the variable strInput
Hope you find it useful.

StringManipulation.xaml (8.3 KB)

Thanks

@MdFuadHasan
Unable to open it.

Hi @Umer_Shahid ,
The file is probably corrupted somehow.
Anyway, here is the screenshot of the workflow. You can build your own from this one.

First, I took the whole text you mentioned in the post in a notepad and read that in the strInput String variable.
Then I have split the whole text with respect to the Uppercase word “INSTRUMENT” and put them into a List of String

strList = strInput.Replace(environment.NewLine,“”).ToUpper.Split(“INSTRUMENT”).ToList

Finally, I removed all other words and kept only the notice number and printed the desired output with String Concatenation for each item of the list.

“Notice Of Change of Address For Service-Instrument “+item.ToString.Trim.Replace(“NOTICE OF CHANGE OF”,””).Trim.Replace("ADDRESS FOR SERVICE- “,” ").trim

Hope this helps you.
Thanks