Lynx
(Lnx)
March 4, 2022, 4:39pm
1
Good morning friends,
I´m trying to make a regex that selects the 4 digits at the end of the word, I have tried like this: but it does not select the numbers
\d{4}$
5 lines:
SMS VARIOS0103 TN 0403
SMS VARIOS1111 SUP3213 0403
SMS VARIOS SAN2 0403
SMS VARIOS SAN 0403
abc1
You should only select 0403 from each line
regards
ppr
(Peter Preuss)
March 4, 2022, 4:42pm
2
Lynx:
\d{4}$
can you try: \d{4}\s*?$
maybe some spaces at the end are not recognized
1 Like
Lynx
(Lnx)
March 4, 2022, 4:45pm
3
ppr:
\d{4}\s*?$
it doesn´t select the digits
lakshman
(Ganta lakshman)
March 4, 2022, 4:51pm
4
@Lynx
I can see it’s working for me. Can you try in below Regex site or you can try directly once in UiPath.
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
1 Like
arivu96
(Arivazhagan A)
March 4, 2022, 4:52pm
5
Hi @Lynx ,
Check below link
\d{4}$
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
Regards,
Arivu
Yoichi
(Yoichi)
March 4, 2022, 4:55pm
6
Hi,
Can you try Mulitiline option, as the following?
Matches activity.
OR
mc = System.Text.RegularExpressions.Regex.Matches(yourString,"\d{4}$",System.Text.RegularExpressions.RegexOptions.Multiline)
mc is MatchCollection
Regards,
1 Like
Lynx
(Lnx)
March 4, 2022, 4:56pm
7
I only tried in https://regexr.com/ , in which you recommend me if it works, I will try it in uipath, thank you very much.
Lynx
(Lnx)
March 5, 2022, 6:27am
8
I want to capture data like:
SMS VARIOS TN 04.03
SMS VARIOS TN 04_03
SMS VARIOS TN 04-03
with : \d{2}-?.?_?\d{2}\s*?$ , but it doesn´t working in uipath
I like use in a variable:
Hi @Lynx ,
Could you try this instead?
String.Join(",",System.Text.RegularExpressions.Regex.Matches(str_txtData,"(?<=[^A-z])[\d._\s-]+(?=\r?\n|\s|$)").Cast(Of Match).Select(Function(s) s.ToString.Trim))
Since there are multiple matches, you have to use Matches
MultipleMatches.xaml (5.0 KB)
Kind Regards,
Ashwin A.K
1 Like
Lynx
(Lnx)
March 5, 2022, 5:10pm
10
The regex will only evaluate line by line, I would like it to capture the last 4 digits in a date (dd-MM). This date can come in 4 types of format ddMM, dd-MM, dd_MM, dd.MM, the date is always the latest.
I tried your regex but it select other numbers more
I also tried this regex before, it works fine on the web, but not on uipath.
In uipath I have it in a variable, but not on uipath:
line= System.Text.RegularExpressions.Regex.Matches(CurrentRow(“Column-1”).ToString,“\d{2}-?.?_?\d{2}\s*?$”)(0).Value
Hi @Lynx ,
Could you try with this pattern instead?
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
System.Text.RegularExpressions.Regex.Matches(CurrentRow(“Column-1”).ToString,"[\d._-]{4,5}(?=$)")(0).Value
Kind Regards,
Ashwin A.K
1 Like
I tried with below expression and it is coming properly.
(\d{2}[\.\-\_]?\d{2})$
I hope, this helps.
Yoichi
(Yoichi)
March 6, 2022, 2:11am
13
Hi,
FYI, \_
doesn’t work in .net regex. (And - is no need to escape.) So your pattern should be as the following.
\d{2}-?\.?_?\d{2}\s*?$
Or
\d{2}[-._]?\d{2}\s*?$
Regards,
1 Like
system
(system)
Closed
March 9, 2022, 2:12am
14
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.