June 25, 2021, 8:35am
I have PDF files and I need to extract 2 values.
for example, Name and phone number.
I create a regex to extract these values as separate. because I need to use this in a different place separately.
my problem is, in some files, I have only one name and one number in another mabey I have 2 or 3, etc… so it is not fixed.
And I need to check if the name = “Any Name”, save the name in a variable and number in another variable.
I can do this if I have one name and number, but I get difficult because I need to create this dynamic.
Also, I can prin all value from regex but how I can use it if condition. I don’t want to use excel if there another way that will be better.
could anyone help me, please?
Is it possbile for you share one example PDF file and what regex you are using to extract name and number?
June 25, 2021, 10:49am
Name.txt (217 Bytes)
I read it from text file.
this the code:
I need number for
Use Matches activity from UiPath.System.Activities package. Use this activity twice. Once with name regex and second time with number regex. The output of this activity is a collection(with all matches found), you can create a variable in the output property by pressing cntrl+k. Now you have names collection and numbers collection.
You can iterate through names collection using for each loop. There’s an option to store Index value in the for each loop properties. Inside the body, if name = Olive, then you can get number by that index. If Numbers is the collection variable name and Index is the index variable name, then you can get by Numbers(Index)
June 25, 2021, 11:19am
June 25, 2021, 11:25am
Inside the body, if name = Olive, then you can get number by that index. If Numbers is the collection variable name and Index is the index variable name, then you can get by Numbers(Index)
could you please explain this more?
Assume that you have saved outputs of your matches activities in variables called “Names” and “Numbers” respectively.
For each name in Names, if name.tostring().equals(“Olive”), then you can get respective number with Numbers(Index). See below screenshot:
As you want number for Olive, you need to do this. Or else, for loop is not needed.
Hope this helps you. Let me know if you still have any doubts.
June 25, 2021, 11:53am
@Surya_Narayana_Korivipadu for your help. it is working fine.
June 28, 2021, 11:53am
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.