Extract data between characters from PDF

I am trying to exact some specific data from a PDF file Using IUPath.

The data in PDF looks like this :

**** hjeprj3 **** James Fish **** JDR0929879 **** jdloin2 B5339 ||

I need to exact the name “James Fish”. It will always have the same format, always **** text **** first name last name **** text And I will always have to extract the name, which will be different.

I used this function : PDFText.Substring(PDFText.IndexOf("**** ",0)+15,16) but as the name will always be diferent it doesn’t return the correct value.

Can you kindly advise?

Thank you for your help

Hi @Alex_Alloin,

Welcome to UIPath community.

Try this and let me know if this works:
PDFText.Substring(PDFText.IndexOf(“",PDFText.IndexOf("”)+1),3,PDFText.IndexOf(“",PDFText.IndexOf("”)+2))

Here, am trying to get the substring between second and third occurance of ****

Thanks,
Arun

Hello @ArunVelaayudhanG,

I copied your function and here is the error I got :

Error ERROR Compiler error(s) encountered processing expression “PDFText.Substring(PDFText.IndexOf(“”,PDFText.IndexOf("”)+1),3,PDFText.IndexOf(“",PDFText.IndexOf("”)+2))".
Overload resolution failed because no accessible ‘Substring’ accepts this number of arguments. Main.xaml

Thank you for your help.

Hi @Alex_Alloin

You can get the value by

PDFText.Split("****".ToCharArray)(1).ToString

Try this

Thanks
Ashwin S

Hello,
No error on compilation his time.
But is seems that there is a space after the “***” so it returns “”.

Hello, It is working with this :

Strings.Trim(Strings.Split(PDFText.Substring(PDFText.IndexOf("**** “,0)+15,30),”*")(0))

Thank you for your help :slight_smile: