Hello
I have a regex which finds dates output from a MS Access database
\t([0-9]+)/([0-9]+)/([0-9]{4})
I want to import it into MySQL so I replace with
\t\3\2\1
But this changes 28/3/2008 into 2008328 where I want 20080328
I've solved the problem by re-exporting from Access, but is there a tidy way I could have added leading zeroes (like I would in PHP by using printf - which, I believe, is an old C function).
Thanks,
Pete
Formatting dates (like PHP printf)
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
PeteTheBloke
- Posts: 39
- Joined: Fri Apr 22, 2005 8:15 am
- Location: N. Ireland
- Contact:
-
gan
You could run the search and replace twice like shown below.
Search for:
Replace with:
Search for:
Replace with:
If you create macro it can be done with a single click or shortcut key as well. Cannot think of another way of doing this to check if there is 1 or 2 digits and then add a 0 if only 1 digit. Maybe someone else have an idea how to solve that with a single search and replace, but i don't think it can be done.
Search for:
Code: Select all
([0-9]+)/([0-9])/([0-9]{4})Code: Select all
\30\2\1Code: Select all
([0-9]+)/([0-9][0-9])/([0-9]{4})Code: Select all
\3\2\1
Last edited by gan on Tue Jun 10, 2008 2:30 pm, edited 1 time in total.
-
PeteTheBloke
- Posts: 39
- Joined: Fri Apr 22, 2005 8:15 am
- Location: N. Ireland
- Contact: