{"id":2528,"date":"2022-02-11T21:30:56","date_gmt":"2022-02-11T20:30:56","guid":{"rendered":"https:\/\/digitalia.culturanuova.net\/blog\/?p=2528"},"modified":"2022-03-06T20:40:39","modified_gmt":"2022-03-06T19:40:39","slug":"regex-multyipel-replacements","status":"publish","type":"post","link":"https:\/\/digitalia.culturanuova.net\/blog\/?p=2528","title":{"rendered":"regex multiple replacements"},"content":{"rendered":"\n<p>You could have to replace several &#8220;whatever&#8221;, f.e.  in a sql file I had to replace many columns with dates, such as &#8216;2005-08-15&#8217; splitting them in &#8216;2005&#8217;, &#8217;08&#8217;, &#8217;15&#8217;.  <\/p>\n\n\n\n<p>I manage to do it with this code:  <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">find NULL, '(.*?)-(.*?)-(.*?)', NULL, NULL, NULL\nreplace NULL, '\\1', '\\2', '\\3', NULL<\/pre>\n\n\n\n<p>In this way you can replace <code>'2005-08-15', NULL, NULL, NULL<\/code> with <code>'2005', '08', '15', NULL<\/code>, and likewise all the like, such as <code>'2012-06-23', NULL, NULL, NULL<\/code> with <code>'2012', '06', '23', NULL<\/code> and so on.<\/p>\n\n\n\n<p>But, be careful: make a backup of your file before.<\/p>\n\n\n\n<p>another case: if you want replace several digits with the same digits formatted, you can try something like this code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">search: ^    (\\d{2})$\nreplace: &lt;h2><code>cap. \\1<\/code>&lt;\/h2>\\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You could have to replace several &#8220;whatever&#8221;, f.e. in a sql file I had to replace many columns with dates, such as &#8216;2005-08-15&#8217; splitting them in &#8216;2005&#8217;, &#8217;08&#8217;, &#8217;15&#8217;. I manage to do it with this code: find NULL, &#8216;(.*?)-(.*?)-(.*?)&#8217;, NULL, NULL, NULL replace NULL, &#8216;\\1&#8217;, &#8216;\\2&#8217;, &#8216;\\3&#8217;, NULL In this way you can replace &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/digitalia.culturanuova.net\/blog\/?p=2528\" class=\"more-link\">Leggi tutto<span class=\"screen-reader-text\"> &#8220;regex multiple replacements&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[579,565],"tags":[709,227,12],"class_list":["post-2528","post","type-post","status-publish","format-standard","hentry","category-database","category-office","tag-mysql-replace","tag-regex","tag-search-and-replace"],"_links":{"self":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2528"}],"version-history":[{"count":6,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2528\/revisions"}],"predecessor-version":[{"id":2549,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2528\/revisions\/2549"}],"wp:attachment":[{"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalia.culturanuova.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}