Before creating this topic, I had searched in forum but unable to find the apt solution for my scenario.
I want to extract a text between two labels and the two labels may occur more than once in the notepad.
If the two labels repeats twice, then i need to get the text between two labels twice.
Can anyone please help me to find a solution for this scenario.
yah we can use REGEX onthis
–lets get the output from notepad with READ TEXT FILE activity as a string variable
–now use a MATCHES activity where mention this expression “(?<=firstlabel).*(?=secondlabel)”)
and get the output with a variable named outmatches
–now use a FOR EACH activity where pass this variable as input and change the type argument as system.Text.RegularExpressions.Regex.Match
and inside the loop use writeline and mention like this item.ToString
I had used the above regex expression “(?<=firstlabel).*(?=secondlabel)”), but it is throwing an error.
Message: parsing “(?<=firstlabel).*(?=secondlabel))” - Too many )'s.
Exception Type: System.ArgumentException]
Could you please check this issue.
Check the xaml, this may help you.
As of now it is working for two occurrences, if you need to more occurrences then have to increase the startIndex and endIndex value part’s +1 to +2 or some number you want.
ExtractStringBetweenTwoStrings.xaml (5.7 KB)
It is getting only the second occurrence value, had changed to +1 but no use. Could you please check it @Palaniyappan
Can you let me know on which occurrence you need to extract the text.
If you have 3 times “want” then start from the third “want” and if you have 4 times “Check” then need to end with the 4th “check”?
Can we run this code in for each loop and get the text between two labels?
Yes, you can. Place the whole activities inside a for each then try.
May I know what going to be there in the for each?
As you had earlier mentioned that , we gonna change the occurrence value +1 or +2. But i don’t know how many occurrences will occur. then how can i iterate this code in for each loop.
@sanju_RPA Do you know the word ?
Please check the attached file.
In this i need to extract the text between “PATH 1” and “Next” and these labels may repeat more than once.
See this: Test.xaml (9.3 KB)
Unable to view the Activity, may i know what is the package for this activity.
it is the uipath.core.activities, im on version 19.8.0
I’m on version 19.1.0
the activity is missing, may i know what is that activity.
Activity is Uipath.core.activities.Matches