I’m trying to understand the RegexBox “(.*?) Matches”
In input i sent a String Variable
My pattern is working fine as regex (finding special caracter to return the X caracters before)
The result is a brand new Variable
When i’m trying to confirm that my expression is working fine it returns “System.Linq.Enumerable+d__94`1[System.Text.RegularExpressions.Match]” as a result. This is a quite a big message compared to the few letters that i was expecting
Any idea ? I tried to modifiy my variable type, but UI Path is requesting “IEnumerable” type
The output is a “Collection” (meaning a data table ?). So to work with your “collection” (in my case 1 word) you have to “Assign” it to a String Variable like this :
You can use For each activity. In Values option you put the Collection of Matches. And change the variable type of item to System.Text.RegularExpressions.Match. And then a Write line activity.
Hi, I try to write all the items but 2 with conditions into a txt file.
I replace the “Write line” with Write Text" but it doesn’t won’t work because it is replacing the file every time…
You can use the ‘Append Line’ activity instead of the ‘Write Text’ activity.
Just specify the name of the file you’d like to use (it will create a new one if it doesn’t exist already) and it should work. If you want each match to be on a new line, you can change it to item.tostring + environment.newline.
Dave, it works perfectly !! Also, regex is a better and more straightforward approach to my case. Learning a bit more everyday - Thank you very much! You the best
EDIT: It is supposed to be for word documents, but I think it works for .txt files as well. I’ve never used it though.
Another approach would be to store it as a string or list of strings, then write the full string out in a write text file activity after the For Each loop completes
Assumptions: There won’t be any newline characters between the first t in tei and the last f in .pdf
How it works:
tei - This finds the 3 characters tei that must be in a row without any other characters between them
.* - This uses the . character which is a wildcard that matches everything except newline characters in conjunction with * which matches the preceding character 0 or more times
\.pdf - This finds the 4 characters .pdf that must be in a row without other characters between them. Since . is a special character in regex, it must be escaped by preceding it with a backslash \
Regex doesn’t use the asterisk * as a wildcard for any character like you’re used to, an approximation of the * in VB.NET regex would be the period/full stop character . which matches any character except newline.