<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Remove&#x2F;Replace everything between two strings?]]></title><description><![CDATA[<p dir="auto">I have several hundred lines of the following:</p>
<p dir="auto">‘&lt;div id=“bodyContent”&gt;’+</p>
<p dir="auto">‘&lt;p&gt;After construction began in …&lt;/p&gt;’ +</p>
<p dir="auto">‘&lt;p&gt;&lt;a href=“<a href="http://www.com" rel="nofollow ugc">http://www.com</a>”&gt;&lt;/p&gt;’ +</p>
<p dir="auto">I need all of the middle content removed but for all several hundred listings.</p>
<p dir="auto">So:</p>
<p dir="auto">‘&lt;div id=“bodyContent”&gt;’+</p>
<p dir="auto">REMOVE ALL OF THIS FOR EVERY INSTANCE</p>
<p dir="auto">‘&lt;p&gt;&lt;a href=“<a href="http://www.com" rel="nofollow ugc">http://www.com</a>”&gt;&lt;/p&gt;’ +</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/18632/remove-replace-everything-between-two-strings</link><generator>RSS for Node</generator><lastBuildDate>Sun, 14 Jun 2026 04:40:25 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18632.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Dec 2019 15:04:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Remove&#x2F;Replace everything between two strings? on Wed, 18 Dec 2019 17:30:03 GMT]]></title><description><![CDATA[<p dir="auto">THANK YOU. Worked perfect. Thank you thank you</p>
]]></description><link>https://community.notepad-plus-plus.org/post/49271</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/49271</guid><dc:creator><![CDATA[Matthew Kampff]]></dc:creator><pubDate>Wed, 18 Dec 2019 17:30:03 GMT</pubDate></item><item><title><![CDATA[Reply to Remove&#x2F;Replace everything between two strings? on Wed, 18 Dec 2019 17:04:25 GMT]]></title><description><![CDATA[<p dir="auto">Since you assure us that’s what your data looks like:</p>
<pre><code>‘&lt;div id=“bodyContent”&gt;’+

‘&lt;p&gt;After construction began in …&lt;/p&gt;’ +

‘&lt;p&gt;&lt;a href=“http://www.com”&gt;&lt;/p&gt;’ +
</code></pre>
<p dir="auto">will become</p>
<pre><code>‘&lt;div id=“bodyContent”&gt;’+



‘&lt;p&gt;&lt;a href=“http://www.com”&gt;&lt;/p&gt;’ +
</code></pre>
<p dir="auto">using the regex</p>
<ul>
<li>FIND = <code>(\Q‘&lt;div id=“bodyContent”&gt;’+\E\R+)(?s:.*?)(\R+\Q‘&lt;p&gt;&lt;a href=“http://www.com”&gt;&lt;/p&gt;’ +\E)</code></li>
<li>REPLACE = <code>$1$2</code></li>
</ul>
<p dir="auto">If your data doesn’t actually have smart quotes, you will need to fix the quotes used in the regex.  Good luck.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/49268</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/49268</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 18 Dec 2019 17:04:25 GMT</pubDate></item><item><title><![CDATA[Reply to Remove&#x2F;Replace everything between two strings? on Wed, 18 Dec 2019 16:34:51 GMT]]></title><description><![CDATA[<pre><code>‘&lt;div id=“bodyContent”&gt;’+

‘&lt;p&gt;After construction began in …&lt;/p&gt;’ +

‘&lt;p&gt;&lt;a href=“http://www.com”&gt;&lt;/p&gt;’ +
</code></pre>
<p dir="auto">remove =</p>
<pre><code>‘&lt;p&gt;After construction began in …&lt;/p&gt;’ +
</code></pre>
<p dir="auto">from:</p>
<pre><code>‘&lt;div id=“bodyContent”&gt;’+



‘&lt;p&gt;&lt;a href=“http://www.com”&gt;&lt;/p&gt;’ +
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/49267</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/49267</guid><dc:creator><![CDATA[Matthew Kampff]]></dc:creator><pubDate>Wed, 18 Dec 2019 16:34:51 GMT</pubDate></item><item><title><![CDATA[Reply to Remove&#x2F;Replace everything between two strings? on Wed, 18 Dec 2019 16:03:07 GMT]]></title><description><![CDATA[<p dir="auto">We could come up with a regex based on that sketchy description, but then you’d tell us it didn’t work, and we’d have to drag it out of you what your data <em>really</em> looks like, and we’d all waste a lot of our time with the back and forth.  If instead, you give us a clear before and after for the text, and reasonable description of the match, using the forum’s tools for marking up code/plaintext so that we know what the data really looks like, rather than trying to guess how the forum mangled it, there’s a much better chance of first-pass success.  See my boilerplate below, especially the forum where it circles the button you have to hit to mark text as code/plaintext, and where it describes my mental process: give us the first half of step #3.</p>
<p dir="auto">-----</p>
<h3>Please Read And Understand This</h3>
<p dir="auto">FYI: I often add this to my response in regex threads, unless I am sure the original poster has seen it before. Here is some helpful information for finding out more about regular expressions, and for formatting posts in this forum (especially quoting data) so that we can fully understand what you’re trying to ask:</p>
<blockquote>
<p dir="auto">This forum is formatted using <a href="https://daringfireball.net/projects/markdown/syntax" rel="nofollow ugc">Markdown</a>. Fortunately, it has a formatting toolbar above the edit window, and a preview window to the right; make use of those. The <code>&lt;/&gt;</code> button formats text as “code”, so that the text you format with that button will come through literally <img src="https://camo.nodebb.org/e4687162a6c7862b83614673105583531335560e?url=https%3A%2F%2Fi.imgur.com%2FKOsSLNe.png" alt="" class=" img-fluid img-markdown" />; use that formatting for example text that you want to make sure comes through literally, no matter what characters you use in the text (otherwise, the forum might interpret your example text as Markdown, with unexpected-for-you results, giving us a bad indication of what your data really is). Images can be pasted directly into your post, or you can hit the image button. (For more about how to manually use Markdown in this forum, please see <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/4">@Scott-Sumner’s post in the “how to markdown code on this forum” topic</a>, and my updates <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/9">near the end</a>.) Please use the preview window on the right to confirm that your text looks right before hitting SUBMIT. If you want to clearly communicate your text data to us, you <em>need</em> to properly format it.</p>
</blockquote>
<blockquote>
<p dir="auto">If you have further search-and-replace (“matching”, “marking”, “bookmarking”, regular expression, “regex”) needs, study <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">the official Notepad++ searching using regular-expressions docs</a>, as well as <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">this forum’s FAQ</a> and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting, see the paragraph above.</p>
</blockquote>
<blockquote>
<p dir="auto">Please note that for all regex and related queries, it is best if you are explicit about what needs to match, <em>and</em> what <em>shouldn’t</em> match, and have multiple examples of both in your example dataset. Often, what <em>shouldn’t match</em> helps define the regular expression as much or more than what <em>should match</em>.</p>
</blockquote>
<blockquote>
<p dir="auto">Here is the way I usually break down trying to figure out a regex (whether it’s for myself or for helping someone in the forum):</p>
</blockquote>
<blockquote>
<ol>
<li>Compare what portions of each line I want to match is identical to every other one (“constants”), and what parts do I want to allow to be different in each line (“variables”) but still be part of the match.</li>
</ol>
</blockquote>
<blockquote>
<ol start="2">
<li>Look at both the variables and constants, and see what portions of each I’ll want to keep or move around, vs which parts get thrown away completely. Each sub-component that I want to keep will be put in a regex group. Anything that gets completely thrown away doesn’t <em>need</em> to be in a group, though sometimes I put it in a numbered <code>(___)</code> or unnumbered <code>(?:___)</code> group anyway, if I have a good reason for it. Anything that needs to be split apart, I break into multiple groups, instead of having it as one group.</li>
</ol>
</blockquote>
<blockquote>
<ol start="3">
<li>For each group, I do a mental “how would I describe to my son how to correctly match these characters?” – which should hopefully give me a simple, foolproof algorithm of characters that must match or must not match; then I ask, “how would I translate those instructions into regex sequences?” If I don’t know the answer to the second, I read documentation, or ask a specific question.</li>
</ol>
</blockquote>
<blockquote>
<ol start="4">
<li>try it, debug, iterate.</li>
</ol>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/49266</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/49266</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 18 Dec 2019 16:03:07 GMT</pubDate></item></channel></rss>