LauraMM
(Laura)
November 16, 2020, 11:48am
1
Thanks for the awesome help!
I have strings with either
“asdaas
Total 23343 asda
blabla
asdasda”
or
“asda
Total, sum 54634 ghjfr
xyzblablalnlabla
asdsa”
How do I match both 23343 and 54634. E.g. I need to match the Total, but it could either be after Total or Total, sum.
The OR in Regex is “|”, quindi (Total | Total, sum)
1 Like
LauraMM
(Laura)
November 16, 2020, 11:56am
3
Cool. Can I make such that if both “Total” and “Total Sum” are present ( I dont know the order), then it should take “Total, sum”?
Or maybe you need not extract text after Total or Total, sum
but rather extract only digits?
If so, try \d+
1 Like
LauraMM
(Laura)
November 16, 2020, 12:00pm
5
Yeah, but I could have digits later in the string as well, so I cant use that. Sorry.
Yes, the order matters.
You are right, you need to use (Total, sum | Total)
The regex evaluate first if “Total, sum” exist and then if “Total” exist
LauraMM
(Laura)
November 16, 2020, 12:17pm
7
No thats not the case in UiPath. I’ve just tried with a Matches and the IENumerable contains both Total, sum and Total matches if they both exists in the string. I only want to have the Total, sum in the IENumerable
Can you write the Regex you used?
ptrobot
November 16, 2020, 12:29pm
9
How about skipping the OR operator and making “, sum” optional instead?
(?<=Total(, sum)? )\d+
? means match 0 or 1 instance.
2 Likes
LauraMM
(Laura)
November 16, 2020, 12:30pm
10
Gabriele_Camilli:
(Total | Total, sum)
(?<=Total|Total sum)(\d*(?=))
LauraMM
(Laura)
November 16, 2020, 12:38pm
11
Cool, but I get an error, when putting your pattern into regex101?
ptrobot
November 16, 2020, 12:39pm
12
You need to check the below option:
But the pattern will work when you use it in UiPath.
You wrote:
But i see
LauraMM:
Total, sum 54634 ghjfr
Try using
(?<=Total |Total, sum )(\d*(?=)) if that’s the case
1 Like
system
(system)
Closed
November 19, 2020, 12:41pm
14
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.