Hello
I am trying to catch the text after the word Uipath in this text
The length and words in the pdf / text files are not always the same. But the word Uipath wil always be in the text
Hello
I am trying to catch the text after the word Uipath in this text
The length and words in the pdf / text files are not always the same. But the word Uipath wil always be in the text
Thanks
for pointing in the right direction
I found this line in another topic:
outputtextpdf.Split({“Uipath”},System.StringSplitOptions.None)(1).Trim.Split(System.Environment.Newline(0))(0).Trim
and used it in a A+B Assign (activity?)( is it the right name? In in another automation program we call it Node)
and it works
i don’t understand it fully
Trying to learn
Maybe there are other ways to find the needed strings. I like to know it
@nicostegeman Try below command i made some changes. It will work
(outputtextpdf.Split({“Uipath”},System.StringSplitOptions.None)(1).Trim).Split({Environment.Newline},StringSplitOptions.None)(0).Trim
@nicostegeman u can also substring method.
For example i like to know why is Uipath written between Curly braces?
@nicostegeman we are using .net methods here, Thats we use same syntax here also
How can i also use substring method?
i know to use the substring method the following way:
outputtextpdf.Substring(0,10) but that gives not what i want
outputtextpdf.Substring({“UiPath”},0,10) dont work
outputtextpdf.Substring(0, outputtextpdf.IndexOf(“UiPath”)) removes UiPath and every thing after it
If you really want to use the SubString method, you can try reading into it here:
I would suggest trying this one:
outputtextpdf.Substring(outputtextpdf.IndexOf(“Uipath”))
Thanks for the info
And thanks for this one:
outputtextpdf.Substring(outputtextpdf.IndexOf(“Uipath”))
i a understand now what indexof does.
But this line gives me the word Uipath and all the words after Uipath. I only need the line after Uipath
so i tried this:
outputtextpdf.Substring(outputtextpdf.IndexOf(“Uipath”)+6,20)
But that is working always because the length off the string after Uipath can change
Personally, I would use a simple Regex:
(?<=Uipath ).+
With a simple assign activity you can get what you want:
outputText = System.Text.RegularExpressions.Regex.Match(inputString,“(?<=Uipath ).+”)
See attached xaml file for reference:
RegexSolution.zip (1.6 KB)
Thanks loginerror
i put it in a assign activity and it works
And i found the regex101.com site and that helps me to understand the “simple” Regex
Also thanks for the xaml file. But that gives me another question. The Regex solution activity runs good. But with that activity i can not write it to another activity.
Is it possible to write the outcome off that activity to another activity?
And in my Activities browser i can not find that Regex solution activity
Where do i find that Activity?
I used a simple Log Message activity to display the result. I changed the title from “Log message” to “Regex solution”, maybe that is why you got confused that it is a different activity than Log message.
To assign your result to a new variable, simply add an Assign activity and fill the fields accordingly:
yourStringVariable = System.Text.RegularExpressions.Regex.Match(inputString,“(?<=Uipath ).+”)
Like that:
You can also look into the Activity called “Matches” that would do similar lookup.
Thanks
Log message i found the activity
A lot of thanks @Manjuts90 and @loginerror
i learned a lot
I have now 4 different solutions
I marked the regex method as the solution.
(I learned a lot off that method thanks to the online regex tester)
Cheers