Input Data -
ID
Name
Location
PrimaryPhoneNo/AlternatePhoneNo
100
Amit
Banglore
5678945379#$9785463241
101
Ajay
Hyderabad
7985679128&9796951269
102
Ramesh
Pune
9965423781*@5671439856
103
Suresh
Delhi
9561796456^@*#9552706398
Expected Output-
Name
Primary Number
Alternate Number
Amit
5678945379
9785463241
Ajay
7985679128
9796951269
Ramesh
9965423781
5671439856
Suresh
9561796456
9552706398
To extract alternate number, i have written this expression in assign activity, but its giving error,
CurrentRow(“PrimaryPhoneNo/AlternatePhoneNo”).ToString.Split(“#”.ToCharArray)(1).Split(“&”.ToCharArray)(1).Split(“@”.ToCharArray)(1).Split(“*”.ToCharArray)(1).Split(“$”.ToCharArray)(1).Split(“^”.ToCharArray)(1)
Error -
Is there any way to resolve this error…
1 Like
gRao
March 7, 2024, 6:06am
2
Hi @NILESH.BOT369 ,
Few quick qns,
1.Are u expecting always an alternate number after the Primary number?
2.If Answer to 1 is Yes,then is the alternate number always a 10 digit number ?
3.If Answer to 2 is Yes, then you can just extract 10 letters from the last/end of the string by using substring method
1 Like
Thank you for your reply,
Yes
No.
1 Like
gRao
March 7, 2024, 6:10am
4
Hi @NILESH.BOT369 ,
Length of the Alternate Number is not always 10?But I see from your example the ALternate Numbers are 10 digits
9785463241
9796951269
5671439856
9552706398
Could you confirm
1 Like
Yes, but lets consider alternate numbers are not 10 Digit numbers for our example.
1 Like
Yoichi
(Yoichi)
March 7, 2024, 6:14am
6
Hi,
Can you try the following sample?
dtResult = dt.AsEnumerable.Select(Function(r) dtResult.LoadDataRow({r(1),System.Text.RegularExpressions.Regex.Match(r(3).ToString,"\d+").Value,System.Text.RegularExpressions.Regex.Match(r(3).ToString,"\d+$").Value},False)).CopyToDataTable
Sample
Sample20240307-3.zip (9.4 KB)
Regards,
3 Likes
vrdabberu
(Varunraj Dabberu)
March 7, 2024, 6:17am
7
HI @NILESH.BOT369
Please check the below xaml and the attached excel file:
TIME.xlsx (10.6 KB)
Sequence40.xaml (11.8 KB)
Regards
2 Likes
gRao
March 7, 2024, 6:33am
8
If thts the case You can try the below steps:
Replacing anything character other than 0-9 with A
Then fetch the numbers:
Primary No= StrVar.Substring(0,System.text.RegularExpressions.Regex.Replace(StrVar,“[^0-9]”,“A”).IndexOf(“A”))
AlternateNo=StrVar.Substring(System.text.RegularExpressions.Regex.Replace(StrVar,“[^0-9]”,“A”).LastIndexOf(“A”)+1)
2 Likes
Hello @vrdabberu ,
LINQ works perfect , thank you…
@Yoichi
Works perfect, thank you…
1 Like
Hi @gRao ,
Thank you,
Works perfect…
“/d+$” this matches multiple digits from right end, is this correct understanding?
Yoichi
(Yoichi)
March 7, 2024, 7:53am
13
Nope. It’s necessary to use backslash instead of slash as the following.
\d+$
Sorry, My Bad,
“\d+$” this matches multiple digits from right end, is this correct understanding now?
Yoichi
(Yoichi)
March 7, 2024, 8:34am
15
Yes, your understanding is right. The following explanation also helps you.
1 Like
Ohh, Got it,
May i know where are you seeing this window?
Yoichi
(Yoichi)
March 7, 2024, 8:39am
17
It’s regex101.
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.
Please note that it’s necessary to check .net(C#) at Flavor if you need to check/buid regex pattern for UiPath.
Regards,
Thank you,
This really helps…
1 Like
system
(system)
Closed
March 10, 2024, 8:46am
19
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.