{"id":5095,"date":"2017-03-14T12:28:47","date_gmt":"2017-03-14T12:28:47","guid":{"rendered":"http:\/\/fluffytech.co.uk\/fluff\/?p=5095"},"modified":"2018-09-21T16:39:14","modified_gmt":"2018-09-21T15:39:14","slug":"grep","status":"publish","type":"post","link":"https:\/\/www.fluffytech.co.uk\/fluff\/grep\/","title":{"rendered":"GREP"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5121\" src=\"https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/gerp-scribble.png\" alt=\"\" width=\"200\" height=\"87\" title=\"\" srcset=\"https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/gerp-scribble.png 200w, https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/gerp-scribble-30x13.png 30w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/p>\n<p>Ok, so you&#8217;ve got an exported xml of all posts from a trusty old WPblog, but before you magically dump all this content into your shinny new website, your client wants all the images removed from the posts because nobody bothered about copyright, but suddenly they do.<\/p>\n<p>These are not featured images either, they are embedded inline and even if you unattached each image and deleted the each image from the media library, the code would still be there in the post body content, with the alt tag showing&#8230;<\/p>\n<p> <em>OO &#8211; I thought. I&#8217;ll do a search + replace&#8230; but hang on, all the images have different image names&#8230; hmmm &#8211; I need a tool to search and replace content between html tags<\/em><\/p>\n<p>Never fear <strong>GREP<\/strong> is here&#8230;<br \/>\n (<i><b>g<\/b>lobally search a <b>re<\/b>gular expression and <b>p<\/b>rint<\/i>)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5097\" src=\"https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/gerp.jpg\" alt=\"\" width=\"626\" height=\"234\" title=\"\" srcset=\"https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/gerp.jpg 626w, https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/gerp-210x78.jpg 210w, https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/gerp-30x11.jpg 30w\" sizes=\"auto, (max-width: 626px) 100vw, 626px\" \/><\/p>\n<p>All you need <a href=\"http:\/\/www.barebones.com\/products\/textwrangler\/\" target=\"_blank\" rel=\"nofollow noopener\">TEXT Wrangler<\/a> (FREE download) or <a href=\"http:\/\/www.barebones.com\/products\/bbedit\/\" target=\"_blank\" rel=\"nofollow noopener\">BBEdit<\/a><\/p>\n<p> And a special bit of code in the search and replace box.<\/p>\n<p> Find images with this code:<\/p>\n<p> <code>&lt;img (.*?)\/&gt;<\/code><\/p>\n<p> Find links with this code:<\/p>\n<p> <code>&lt;a(.*?)&lt;\/a&gt;<\/code><\/p>\n<p> Just tick the GREP box&#8230;<\/p>\n<p> CLEAN WITH GREP<\/p>\n<p>How to strip HTML code using \u2018Grep\u2019 in Text Wrangler:<\/p>\n<p> 1. Open document to be stripped of code;<br \/>\n 2. Click: Search =&gt; Find \u2026<br \/>\n \u00a03. In the Find field put:<\/p>\n<p> <code>\u00a0&lt;\/?[^&gt;]*&gt;<\/code><\/p>\n<p> 4. Select: Grep<br \/>\n 5. Click Replace All.<\/p>\n<p> <span data-dobid=\"hdw\">Courtesy<\/span> of <a href=\"http:\/\/bcdwp.web.tamhsc.edu\/webmaster\/2011\/08\/12\/how-to-strip-html-code-using-grep-in-text-wrangler\/\" target=\"_blank\" rel=\"nofollow noopener\">Art Upton<\/a> &#8211; <em>thanks man<\/em><\/p>\n<p> If you want to know more about GERP &#8211; try <a href=\"http:\/\/www.anybrowser.org\/bbedit\/grep.html\" target=\"_blank\" rel=\"nofollow noopener\">Cari D. Burstein&#8217;s excellent explaination<\/a> from 2004 &#8211; or if all else fails, let <a href=\"https:\/\/www.fluffytech.co.uk\/fluff\/we-dont-just-listen-we-guess-too\/\" target=\"_blank\">Physicist Richard Feynman<\/a> try and explain.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Find + Replace html strings&#8230;<\/p>\n","protected":false},"author":6,"featured_media":5121,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[35,1,41],"tags":[],"class_list":["post-5095","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fluffy-tech-tips","category-random-mix","category-wordpress",""],"_links":{"self":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/posts\/5095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/comments?post=5095"}],"version-history":[{"count":0,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/posts\/5095\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/media\/5121"}],"wp:attachment":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/media?parent=5095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/categories?post=5095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/tags?post=5095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}