Hi! So I’m trying to create a process where I’ll create and send a verification code, with a certain format. I’m thinking of doing it like this CCCNNNNN where C is Char and N is a number/int. So for example it will be like, HJX71395. I hope you can help me, thank you.
You can random string and rNdom number activity for creating this. Create both and concantenate it.
WE can use random Numbers and also map Numbers to Letters for the Generation
Have a Look on
The Mod function
How about the following?
System.Text.RegularExpressions.Regex.Replace(format,"C|N",Function(m) if (m.Value="C",Chr(rnd.Next(65,90)).ToString ,if(m.Value="N",Chr(rnd.Next(48,57)),"-")))
Sequence5.xaml (5.8 KB)
Please try the below,
String.Join(String.Empty, Enumerable.Range(0, 3).Select(Function(i) Convert.ToChar(new Random().Next(65,90)))) + new Random().Next(11111,99999).ToString
Here is the project ref from UiPath Studio Web -
nmnithinkrishna_RandomVerificationCodeGenerator.zip (1.9 KB)
Hope this helps.
I think this works too, though it prints the other way around. Instead of CCCNNNN, it goes NNNNNCCC.
Thanks! This works perfectly well for me.
Oh sorry for that
Just reverse the concatenation operands
Updated the above
Thanks! also works well using this
String.Join(String.Empty, Enumerable.Range(0, 3).Select(Function(i) Convert.ToChar(new Random().Next(65,90))))+new Random().Next(11111,99999).ToString
I think this one looks cleaner as it doesn’t need to use more than one Assign Activity.
Cool with whichever you are comfortable
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.