Search code examples
regexnotepad++

Notepad++ Regex - Replace a blank space in dates


I have a large export file from a legacy computer system. The dates that get exported have a [space] instead of a 0 for all single digit days or months:

1/ 1/2015 (dd/MM/yyyy)

The first space is not a problem but the second space is.

I have tried to search and replace /[space] but this will replace any occurrences of /[space] in the data file - not only in dates.

I have also tried to use regex find and replace as follows:

Find: / [0-9]/[0-9]+

Replace: /0[0-9]/[0-9]+

The intended out come should be:

Original: 1/ 1/2015

New: 1/01/2015

However I got:

Actual: 1/0[0-9]/[0-9]+


Is this even possible in Notepad++ or do I have to use MS Excel?

Thanks


Solution

  • Find : (\b\d{1,2}/) +(\d{1,2})(?=/\d{4}\b)

    Replace : \1\2

    DEMO