Regex - remove everything but "dd/MM/yyyy" from a string


I am currently working on a process with a lot of string manipulation. I need to get three dates from a string that will be in a consistent order, but the rest of the data positions are inconsistent. I’d like to remove all characters from a string that isn’t a date in the format “dd/MM/yyyy”.

Example string: 20/10/2020 6741002 1042687,William Coulson, ISP, From 20280935 6,364.24 12/10/2020 - To 08/11/2020, ‘Service Level Example string - (Forum Specific) (Placement)’, SPOT,

I have got a Regex for removing the date, but I need it the other way round.

Has anybody done this before for similar instances? Or can help me with the above instance?

Thanks in advance.

Regex :


It will give you a list of all the dates only…

1 Like

In that case, all you want is to extract the dates right??

If not, what is the about you are expecting from the below text??

Because this pattern will extract the dates ignoring the other texts …

Thanks! That worked!

I am aware of the fact that the regex pattern I supplied is the opposite of what I wanted. Hence why I said so. Thought it may have helped to point out the pattern supplied is not what I wanted…

Then if you use my pattern, you can easily get the output you wanted…right??

Same logic using string .join…

Hi @prasath17,

As @Pravin_Patil1 responded first and I tried his solution first, I marked his as the solution. I can confirm yours works too, as I tried that after I tried @Pravin_Patil1’s solution and marked it as the solution. Thank you for your time :slight_smile:

1 Like

@william.coulson - that’s fine…I am not looking for my post to be marked as solution, what I meant is my pattern is simple and easy to use…that’s all…

1 Like

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