<?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[Simple text clean up]]></title><description><![CDATA[<p dir="auto">I have exported g.code from cura to a txt file. My mission is to create a animation of 3D printing in blender with python. So I just need to do some basic deleting of the g.code and I want to leave the coordinate info behind. So I downloaded notepad++ and this is what I have to do</p>
<p dir="auto"><strong>G1 X184.218 Y123.524 E1.81219</strong> - I want to keep only the info after X Y<br />
<strong>G1 X183.179 Y125.34 E1.83974</strong><br />
<strong>M204 S625</strong> - I want to delete everything in this section except the the last line<br />
<strong>M205 X10 Y10</strong><br />
<strong>G0 F2571.4 X182.84 Y125.092</strong><br />
<strong>M204 S500</strong><br />
<strong>G1 X183.179 Y125.34 E1.83974</strong> - Then it all repeats<br />
<strong>G1 X183.179 Y125.34 E1.83974</strong></p>
<p dir="auto">The question is how do I do that, I know this is really simple but for the love of god I cant figure it out, so do you know how to do it?</p>
<p dir="auto"><a href="https://drive.google.com/file/d/1iRhHJdNw8RQ2fv7W6x-kJwG3bHUDW0qS/view?usp=sharing" rel="nofollow ugc">https://drive.google.com/file/d/1iRhHJdNw8RQ2fv7W6x-kJwG3bHUDW0qS/view?usp=sharing</a> - The g.code</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20036/simple-text-clean-up</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 04:40:10 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20036.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Sep 2020 16:49:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Simple text clean up on Wed, 23 Sep 2020 18:10:39 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/adam-labu%C5%A1" aria-label="Profile: adam-labuš">@<bdi>adam-labuš</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>, @m_andre_z_eckenrode and <strong>All</strong>,</p>
<p dir="auto">Ah, <strong>OK</strong> ! With your <strong>new</strong> specifications, it’s <strong>easier</strong> to get the <strong>right</strong> regex, at once ;-))</p>
<p dir="auto">But when you said :</p>
<blockquote>
<p dir="auto">For the other lines I want to delete everything else except lines that looks like this</p>
<p dir="auto"><strong>;LAYER:1</strong></p>
</blockquote>
<p dir="auto">We don’t know if you speak of lines which <strong>begin</strong>, <strong>contain</strong> or <strong>end</strong> with <strong><code>;LAYER:1</code></strong> ! I suppose that it is <strong>which begin…</strong></p>
<hr />
<p dir="auto">Then, from this <strong>simple</strong> example, below :</p>
<pre><code class="language-diff">G1 X184.218 Y123.524 E1.81219
G1 X183.179 Y125.34 E1.83974
M204 S625
;LAYER:1 bla bla blah
M205 X10 Y10
G0 F2571.4 X182.84 Y125.092
M204 S500
G1 X183.179 Y125.34 E1.83974
</code></pre>
<p dir="auto">The following regex S/R</p>
<p dir="auto">SEARCH <strong><code>(?-si)^G[01].+(X\d+\.\d+\x20Y\d+\.\d+).*|^(?!;LAYER:1).+\R</code></strong></p>
<p dir="auto">REPLACE <strong><code>\1</code></strong></p>
<p dir="auto">would <strong>output</strong> this text :</p>
<pre><code class="language-diff">X184.218 Y123.524
X183.179 Y125.34
;LAYER:1 bla bla blah
X182.84 Y125.092
X183.179 Y125.34
</code></pre>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">The <strong>in line</strong> modifiers <strong><code>(?-si)</code></strong> mean that :</p>
<ul>
<li>
<p dir="auto">Any <strong>dot</strong> regex symbol represents a <strong>single standard</strong> character and <strong>not</strong> <strong>EOL</strong> chars, as <strong><code>\r</code></strong> or <strong><code>\n</code></strong> <strong><code>(?-s)</code></strong></p>
</li>
<li>
<p dir="auto">The search is run in a <strong>non-insensitive</strong> way <strong><code>(?-i)</code></strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto">Then the <strong>search</strong> regex contains <strong>two</strong> alternatives, <strong>separated</strong> with the <strong><code>|</code></strong> symbol :</p>
<ul>
<li>
<p dir="auto">The regex <strong><code>^G[01].+(X\d+\.\d+\x20Y\d+\.\d+).*</code></strong></p>
<ul>
<li>
<p dir="auto">The part <strong><code>^G[01]</code></strong> looks for strings <strong>G0</strong> or <strong>G1</strong>, <strong>beginning</strong> current line</p>
</li>
<li>
<p dir="auto">The part <strong><code>.+</code></strong> represents any <strong>non-null</strong> range of <strong>standard</strong> characters</p>
</li>
<li>
<p dir="auto">The part <strong><code>(X\d+\.\d+\x20Y\d+\.\d+)</code></strong> search for the <strong>exact</strong> letter <strong><code>X</code></strong>, followed with some digits <strong><code>\d+</code></strong>, followed with a <strong>literal</strong> dot <strong><code>\.</code></strong> followed by <strong>decimal</strong> digits <strong><code>\d+</code></strong> and a <strong>space</strong> char <strong><code>\x20</code></strong> then the <strong>exact</strong> letter <strong><code>Y</code></strong> and … ( <strong>same</strong> process than for <strong><code>X</code></strong> ). As all the part is surrounded by <strong>parentheses</strong>, its contents are <strong>stored</strong> as <strong>group <code>1</code></strong></p>
</li>
<li>
<p dir="auto">Finally, the part <strong><code>.*</code></strong> represents any range of <strong>standard</strong> characters, possibly <strong>null</strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto">The regex <strong><code>^(?!;LAYER:1).+\R</code></strong></p>
<ul>
<li>
<p dir="auto">The part <strong><code>^(?!;LAYER:1)</code></strong> search <strong>all</strong> the lines which <strong>not</strong> begin with the string <strong>;LAYER:1</strong></p>
</li>
<li>
<p dir="auto">And the part <strong><code>.+\R</code></strong> catches all the characters of any <strong>non-null</strong> line <strong><code>.+</code></strong>, with its <strong>line-break</strong> chars <strong><code>\R</code></strong> ( = <strong><code>\r\n</code></strong> for <strong>Windows</strong> files, <strong><code>\n</code></strong> for <strong>Unix</strong> files, or <strong><code>\r</code></strong> for <strong>Mac</strong> files )</p>
</li>
</ul>
</li>
</ul>
</li>
<li>
<p dir="auto">In <strong>replacement</strong> :</p>
<ul>
<li>
<p dir="auto">If the <strong>left</strong> regex matches, then the <strong>group <code>1</code></strong> is <strong>defined</strong> and corresponds to the <strong><code>XY</code></strong> <strong>coordinates</strong>, which must be rewritten =&gt; <strong><code>\1</code></strong></p>
</li>
<li>
<p dir="auto">Else, the <strong>right</strong> regex is used. As <strong>no</strong> group is defined, in the <strong>second</strong> alternative, the pointer to <strong>group <code>1</code></strong> <strong><code>\1</code></strong> return a <strong>null</strong> string. So, the <strong>current matched</strong> line is just <strong>deleted</strong> !</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57863</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57863</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 23 Sep 2020 18:10:39 GMT</pubDate></item><item><title><![CDATA[Reply to Simple text clean up on Wed, 23 Sep 2020 12:53:05 GMT]]></title><description><![CDATA[<p dir="auto">OK so sorry for making this forum thread a mess but after a little reasearch I figured out this<br />
I need to keep all lines starting with G1 and G0 like these two</p>
<p dir="auto"><strong>G1 X181.281 Y127.145 E1.8737<br />
G0 F2571.4 X182.162 Y124.596</strong></p>
<p dir="auto">I want to delete all of the other stuff in these lines and just keep this</p>
<p dir="auto"><strong>X181.281 Y127.145<br />
X182.162 Y124.596</strong></p>
<p dir="auto">For the other lines I want to delete everything else except lines that looks like this</p>
<p dir="auto"><strong>;LAYER:1</strong></p>
<p dir="auto">I have tried what <strong>guy038</strong> said and it worked WONDERFULLY but because of my unclear instructions (I am not a native speaker sorry) the result wasnt what I wanted and because I dont understand the language completely I cannnot modify its instructions to keep the lines that start with G1 and ;LAYER:1 also.<br />
So once again can you guys help?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57853</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57853</guid><dc:creator><![CDATA[Adam Labuš]]></dc:creator><pubDate>Wed, 23 Sep 2020 12:53:05 GMT</pubDate></item><item><title><![CDATA[Reply to Simple text clean up on Tue, 22 Sep 2020 19:11:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/adam-labu%C5%A1" aria-label="Profile: Adam-Labuš">@<bdi>Adam-Labuš</bdi></a> said in <a href="/post/57811">Simple text clean up</a>:</p>
<blockquote>
<p dir="auto"><strong>G1 X184.218 Y123.524 E1.81219</strong> - I want to keep only the info after X Y</p>
</blockquote>
<p dir="auto">Not sure if <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> already got this worked out the way you wanted, but I was going to take a gander at this, and have downloaded a copy of your gcode for further inspection, though I have to admit that it’s far from clear to me what to keep and what to discard. Does every line that contains the X and Y values you want to keep begin with <code>G1</code>?</p>
<p dir="auto">There are also many other lines in your gcode that don’t resemble any of those in your posted examples, especially at the beginning and end of the file. Are those to be ignored in whatever operation we come up with?</p>
<blockquote>
<p dir="auto"><strong>M204 S625</strong> - I want to delete everything in this section except the the last line</p>
</blockquote>
<p dir="auto">You appear to indicate that the ‘last line’ of ‘this section’ is <code>M204 S500</code>, since that’s the line you show as being retained in your <a href="https://community.notepad-plus-plus.org/post/57817">second post</a>, but in your gcode file, I see lots instances of lines with <code>M205 X5 Y5</code> — not shown in any of your posted examples — immediately following those with <code>M204 S500</code>, as in the following data extracted from your gcode:</p>
<pre><code>M204 S625
M205 X10 Y10
G0 F2571.4 X182.84 Y125.092
M204 S500
M205 X5 Y5
</code></pre>
<p dir="auto">So what, exactly, defines ‘this section’?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57826</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57826</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Tue, 22 Sep 2020 19:11:37 GMT</pubDate></item><item><title><![CDATA[Reply to Simple text clean up on Tue, 22 Sep 2020 18:42:44 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/adam-labu%C5%A1" aria-label="Profile: adam-labuš">@<bdi>adam-labuš</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Try this <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-si)^((?!G1).+\R)?G1\x20(X\d+\.\d+\x20Y\d+\.\d+).+|.+\R</code></strong></p>
<p dir="auto">REPLACE <strong><code>\1\2</code></strong></p>
<p dir="auto">The <strong>algorithm</strong> used is :</p>
<ul>
<li>
<p dir="auto"><strong>Any</strong> line, <strong>right</strong> before a line <strong><code>G1 X....</code></strong>, is just <strong>kept</strong></p>
</li>
<li>
<p dir="auto"><strong>Any</strong> line, <strong>beginning</strong> with the <strong><code>G1</code></strong> command, is replaced with the <strong>coordinates</strong> <strong><code>X</code></strong> and <strong><code>Y</code></strong>, <strong>only</strong></p>
</li>
<li>
<p dir="auto"><strong>Any</strong> other line is simply <strong>deleted</strong></p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57824</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57824</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 22 Sep 2020 18:42:44 GMT</pubDate></item><item><title><![CDATA[Reply to Simple text clean up on Tue, 22 Sep 2020 17:41:18 GMT]]></title><description><![CDATA[<p dir="auto">So this is how it looks like now<br />
G1 X184.218 Y123.524 E1.81219<br />
G1 X183.179 Y125.34 E1.83974<br />
M204 S625<br />
M205 X10 Y10<br />
G0 F2571.4 X182.84 Y125.092<br />
M204 S500<br />
G1 X183.179 Y125.34 E1.83974</p>
<p dir="auto">This is how it should look like</p>
<p dir="auto">X184.218 Y123.524<br />
X183.179 Y125.34<br />
M204 S500<br />
X183.179 Y125.34</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57817</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57817</guid><dc:creator><![CDATA[Adam Labuš]]></dc:creator><pubDate>Tue, 22 Sep 2020 17:41:18 GMT</pubDate></item><item><title><![CDATA[Reply to Simple text clean up on Tue, 22 Sep 2020 17:02:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/adam-labu%C5%A1" aria-label="Profile: Adam-Labuš">@<bdi>Adam-Labuš</bdi></a></p>
<p dir="auto">Can’t you just show a <em>before</em> text (which I think you have) and a desired <em>after</em> text?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57814</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57814</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 22 Sep 2020 17:02:48 GMT</pubDate></item></channel></rss>