I use Notepad++ in M$ Windows and Kate in Linux. Both can do Regular expression Search & Replace upon text.
I find regular expressions very useful for preparing date fields prior to import into a database table. So, converting the UK date format
dd/mm/yyyy (12/01/2013) into a MySQL DATE, DATETIME or, TIMESTAMP datatype (2013-01-12) is easy.
Search:
([0-9]+)/+([0-9]+)/+([0-9]+)
Replace (converts UK date format):
\3-\2-\1
Replace (converts US date format):
\3-\1-\2
So the above UK example searches for dates in the UK date format dd/mm/yyyy and converts them to yyyy-mm-dd.
Before:
Click image to enlarge
Click image to enlarge
Nice tutorials on Regular expressions at http://www.regular-expressions.info/
No comments:
Post a Comment