0

I have a list of dates with mixed date format of:

mm/dd/yyyy
yyyy/mm/dd
dd/mm/yy
d/m/yy

In one file. Is there an approach that to use regex to match them and update to the same format: yyyy-mm-dd?

Biffen
  • 5,354
  • 5
  • 27
  • 32
John
  • 64
  • 3
  • 1
    Possible duplicate of [Learning Regular Expressions](https://stackoverflow.com/questions/4736/learning-regular-expressions) – Biffen Feb 09 '18 at 08:32
  • It would be possible with about 6 replaces but not very efficient. Better split each line by /, analyze and return the correct format. – maraca Feb 09 '18 at 08:46
  • This really does not sounds like a good regex task. You'd could chain replacement to converge reduce number of formats and reach the desired one and to "leap" from `yy` to `yyyy`. – Ondrej K. Feb 09 '18 at 09:24
  • 1
    which langauage ? regex engines differs depending on languages, and it may be [possible](https://regex101.com/r/e1HDkn/1) or not, using tricks but not with one unique standard regex – Nahuel Fouilleul Feb 09 '18 at 09:37

0 Answers0