I have a string in the variable “person”. E.G “John Smith JP606060D 01/01/2019 Male”
I want to remove all dates from the string. The date is different in each occurance of person.
I’ve tried using: RegEx.Replace(person.ToString.Trim,“^([0-2][0-9]|(3)[0-1])(/)(((0)[0-9])|((1)[0-2]))(/)\d{4}$”,“”)
but, this only removes the date if the string is “01/01/2019”, but not if it is within a larger string as per the example above
Can anyone assist please? Thanks.
srdjan.suc
(Srdjan Suc)
August 21, 2019, 10:55am
2
Replace.xaml (7.6 KB)
Try this, see if it helps
Pablito
(Pawel Wozniak)
August 21, 2019, 11:04am
3
You can use just this regex:
And the just use index needed for your case (written bellow words in my screen).
Test16.zip (26.9 KB)
I uploaded a file where the input string is “John Smith JP606060D 01/01/2019 Male” and the output string is “John Smith JP606060D Male”.
You can refer to it
1 Like
Thanks everyone. Managed to use @Vivek_Kumar code to get things working.
@Pablito Your code works for the example I gave, but sometimes there are multiple middle names.
@srdjan.suc What was the package for the first activity in your workflow? I can’t get it to load that activity.
1 Like
srdjan.suc
(Srdjan Suc)
August 21, 2019, 12:31pm
6
Ah damn, I need to stop using this BetaFeed.
My Dependencies are:
“dependencies”: {
“UiPath.Excel.Activities”: “[2.6.2]”,
“UiPath.Mail.Activities”: “[1.5.1]”,
“UiPath.System.Activities”: “[19.7.0]”,
“UiPath.UIAutomation.Activities”: “[19.7.0]”
},
Pablito
(Pawel Wozniak)
August 21, 2019, 12:55pm
7
Multiple middle names are not a problem
This regex will mark any word in whole sentence so you can just combine indexes you want to use as a string like:
regex_output(0).ToString + regex_output(1).ToString + regex_output(3).ToString + regex_output(8).ToString etc.
system
(system)
Closed
August 24, 2019, 12:55pm
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.