regex multiple replacements

You could have to replace several “whatever”, f.e. in a sql file I had to replace many columns with dates, such as ‘2005-08-15’ splitting them in ‘2005’, ’08’, ’15’.

I manage to do it with this code:

find NULL, '(.*?)-(.*?)-(.*?)', NULL, NULL, NULL
replace NULL, '\1', '\2', '\3', NULL

In this way you can replace '2005-08-15', NULL, NULL, NULL with '2005', '08', '15', NULL, and likewise all the like, such as '2012-06-23', NULL, NULL, NULL with '2012', '06', '23', NULL and so on.

But, be careful: make a backup of your file before.

another case: if you want replace several digits with the same digits formatted, you can try something like this code:

search: ^    (\d{2})$
replace: <h2>cap. \1</h2>\n

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *