How to replace string value to date format ?some times its coming without "/"

how to replace string value to date format ?some times its coming without “/”?



Regex.Replace(strText, strPattern,"$1/$2")

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

1 Like

if date format is correct it should not change, if its wrong then it should update. will this regex avoid if string is in correct format?

you saw it within the regex101 as it was not matching. Feel also free to run such prototypes within the immediate panel. So you can also prototype by yourself

can we do without regex?

we would recommend Regex, but have a look here:

1 Like

Hello @MitheshBolla ,

Did you tried to set the format for the excel? For that particular column try to set the format as Datetime dd/MM/yyyy in the excel. I hope then whenever if you add a Date in that format it will autocorrect.

1 Like

Actually its a template, so i am unable to edit those. i had to manipulate it in code itself

for c# error is coming bro

was not mentioned before bro

1 Like

my bad. i dint mentioned


Refer the below post.

For c# what changes i need to do bro?

which statement did you focused? Regex or String approach?

1 Like

bro this regex can i have in c#?

regex , as u said its best practise , i had string and string pattern, i am facing issue while replacing

can you try

Regex.Replace(strText,@"(\d{2})(\d{2}\/\d{4})", "$1/$2");


strPattern = @"(\d{2})(\d{2}\/\d{4})"
Regex.Replace(strText,strPattern, "$1/$2");
1 Like

thanks bro

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.