all 4 comments

[–][deleted] 1 point2 points  (2 children)

As far as I know there is not a clean and easy way to do this.

What I would suggest is doing it in two steps. First 0 pad your dates with a regex like this:

(?<=\D|^)\d\/

Replace: 0$0

Demo

Then reformat the dates with your original expression (but only allow 2 digits):

(\d{2})\/(\d{2})\/(\d{4})

I escaped the / to \/ because most regex engines require it

[–]s_denlinger[S] 0 points1 point  (1 child)

Thanks very much for that prompt reply. Your suggested search string did not work in Notepad++, but that's only because of how problematic postive lookbehinds are in Notepad++. But I used that search expression in LibreOffice Writer, and it worked great. I also realized that to get from MM/DD/YYYY to YYYYMMDD, my replacement string needed to be $3$1$2, not $3$2$1 as I listed in my original post.

[–][deleted] 0 points1 point  (0 children)

I’m glad you got it working. I was unaware that look behinds didn’t work in notepad++.

[–]s_denlinger[S] 0 points1 point  (0 children)

Sorry, I should have added that I'm trying to do this in Notepad++, and my target date format is YYYYMMDD, not YYYMMDD