<?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[RegEX - How can I make automatic a  new line (break) at x character]]></title><description><![CDATA[<p dir="auto">Hello,<br />
The makro maker of Notepad++ and TextFX ReWrap is nice but he can’t help by this problem.</p>
<p dir="auto">Example:<br />
My TXT</p>
<pre><code>"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna",
"aliquyam erat, sed diam voluptua.",
"At vero eos et accusam et",
"Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing",
"elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
"At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem",
"ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore",
"et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. ",
"Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
</code></pre>
<p dir="auto">My wish:</p>
<ul>
<li>All lines max. 88 character</li>
<li>Point and less under 88 character than  delete ",  - make the line max. 88 (move up), last right spaces make a break an set a new ",<br />
I hope this is understandable…</li>
</ul>
<p dir="auto">Finish example:</p>
<pre><code>"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor",
"invidunt ut labore et dolore magna aliquyam erat,sed diam voluptua. At vero eos et",
"accusam et Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur",
"sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et, dolore magna",
"aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo",
"dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem",
"ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed",
"diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam",
"voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd", 
"gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
</code></pre>
<p dir="auto">It’s all very complicated but if someone has a solution it would be very helpful.<br />
Many Thanks!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20730/regex-how-can-i-make-automatic-a-new-line-break-at-x-character</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 08:54:49 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20730.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Feb 2021 15:54:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 22:26:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/62773">RegEX - How can I make automatic a new line (break) at x character</a>:</p>
<blockquote>
<p dir="auto">Yes, the documentation that you were linked to could have described that to you</p>
</blockquote>
<p dir="auto">specifically, the section <a href="https://npp-user-manual.org/docs/searching/#multiplying-operators" rel="nofollow ugc">https://npp-user-manual.org/docs/searching/#multiplying-operators</a>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62774</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62774</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 11 Feb 2021 22:26:10 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 22:14:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/robin-cruise" aria-label="Profile: Robin-Cruise">@<bdi>Robin-Cruise</bdi></a> ,</p>
<p dir="auto">Yes, the documentation that you were linked to could have described that to you.</p>
<p dir="auto">The regex portion <code>.{1,85}</code> represents one (1) to eighty-five (85) instances of the <code>.</code> regex, which matches any character (except newline*).  So the whole regex means:</p>
<ul>
<li><code>.{1,85}</code> = find 1 to 85 characters from the start of the line (as many as it can while still matching the rest of the regex)</li>
<li><code>\K</code> = reset the match, so the first part won’t be replaced; this feature requires using REPLACE ALL</li>
<li><code>(\h|$)</code> = find either a space character, or the zero-width end of line (not including newline characters).  This space or zero-width-match at the end of the line will be replaced by whatever is in the REPLACE expression.</li>
</ul>
<p dir="auto">Footnote *: whoops, I should have either specified disabling “. matches newline” or used <code>(?-s)</code> at the start of the regex. sorry: <code>(?-s)^.{1,85}\K(\h|$)</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/62773</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62773</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 11 Feb 2021 22:14:52 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 22:03:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/62750">RegEX - How can I make automatic a new line (break) at x character</a>:</p>
<blockquote>
<p dir="auto">^.{1,85}\K(\h|$)</p>
</blockquote>
<p dir="auto">can anyone tell me what exactly represents the number 1,85 from regex <code>^.{1,85}\K(\h|$)</code> ?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62771</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62771</guid><dc:creator><![CDATA[Robin Cruise]]></dc:creator><pubDate>Thu, 11 Feb 2021 22:03:27 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 17:00:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/62754">RegEX - How can I make automatic a new line (break) at x character</a>:</p>
<blockquote>
<p dir="auto">Which of course makes yours much better!  :-)<br />
My feeling is it could be best to give a general outline, and then if OP has trouble, they can ask for elaboration.  Perhaps the general scheme suffices?<br />
Of course, Peter, you are free to do as you like.</p>
</blockquote>
<p dir="auto">Peter and Alan!<br />
You both helped very well.<br />
Many thanks!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62759</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62759</guid><dc:creator><![CDATA[Venus642]]></dc:creator><pubDate>Thu, 11 Feb 2021 17:00:39 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 16:49:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a><br />
Alan - Thanks  for your help!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62757</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62757</guid><dc:creator><![CDATA[Venus642]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:49:20 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 16:47:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">Your RegEx is wonderfull - Big thanks</p>
<p dir="auto">I would like to thank you very much for your help!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62756</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62756</guid><dc:creator><![CDATA[Venus642]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:47:35 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 16:28:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> said in <a href="/post/62750">RegEX - How can I make automatic a new line (break) at x character</a>:</p>
<blockquote>
<p dir="auto">beat me to the general outline, because I was giving specifics</p>
</blockquote>
<p dir="auto">Which of course makes yours much better!  :-)</p>
<p dir="auto">My feeling is it could be best to give a general outline, and then if OP has trouble, they can ask for elaboration.  Perhaps the general scheme suffices?</p>
<p dir="auto">Of course, Peter, you are free to do as you like.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62754</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62754</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:28:37 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 16:26:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: Venus642">@<bdi>Venus642</bdi></a> said in <a href="/post/62745">RegEX - How can I make automatic a new line (break) at x character</a>:</p>
<blockquote>
<p dir="auto">My wish:</p>
<p dir="auto">All lines max. 88 character<br />
Point and less under 88 character than  delete ",  - make the line max. 88 (move up), last right spaces make a break an set a new ",<br />
I hope this is understandable…</p>
</blockquote>
<p dir="auto">I think you’ll find <a href="https://community.notepad-plus-plus.org/topic/20008/line-wrap-in-the-current-version">this discussion</a> very helpful.</p>
<p dir="auto">Cheers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62752</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62752</guid><dc:creator><![CDATA[Michael Vincent]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:26:24 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 16:24:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> beat me to the general outline, because I was giving specifics:</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: Venus642">@<bdi>Venus642</bdi></a> ,</p>
<p dir="auto">I would do it multistep</p>
<ol>
<li>Get rid of the beginning and end quotes and end commas<br />
FIND = <code>^"|",\h*$</code><br />
REPLACE = empty<br />
SEARCH MODE = Regular Expression<br />
REPLACE ALL</li>
<li>Merge to a single line: in editor, do keystrokes <code>Ctrl+A Ctrl+J</code> (<strong>Edit &gt; Line Operations &gt; Join Line</strong>)</li>
<li>Split the lines into a max of 88:
<ul>
<li>If you had v7.9.3 (which is in <a href="/topic/20710/notepad-7-9-3-rc">release candidate</a> right now), then use <strong>Settings &gt; Preferences &gt; Marings/Border/Edge</strong> and set Vertical Edge Setting to 88 and CLOSE, then <code>Ctrl+I</code> (<strong>Edit &gt; Line Operations &gt; Split Line</strong>)</li>
<li>If you have an earlier version, you could follow my advice in the first reply in <a href="https://community.notepad-plus-plus.org/topic/20581/restore-right-margin-word-wrap-as-in-7-8-5">this other thread</a>, where you temporarily set the editor window’s width such that <code>Ctrl_I</code> (<strong>Split Line</strong>) will split at 88 characters.  Though, because we will be adding back in the opening quote and the end quote and comma, set the width to 85 instead.</li>
<li>If that’s absolutely impossible for you, you can do it with regex, though it’s fragile:<br />
FIND = <code>^.{1,85}\K(\h|$)</code><br />
REPLACE = <code>\r\n</code> (I assume windows newline)<br />
MODE = Regular Expression<br />
REPLACE ALL</li>
</ul>
</li>
<li>Re-add the quotes and commas<br />
FIND = <code>(^\h*$)|(^)|((?&lt;!")$)</code><br />
REPLACE = <code>(?1)(?2")(?3",)</code><br />
MODE = Regular Expression<br />
REPLACE ALL</li>
</ol>
<p dir="auto">With the text you showed, this process (even the regex for step 3) resulted in</p>
<pre><code>"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod",
"tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero",
"eos et accusam et Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur",
"sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna",
"aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea",
"rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit",
"amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod",
"tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero",
"eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea",
"takimata sanctus est Lorem ipsum dolor sit amet."
</code></pre>
<p dir="auto">which does meet the 88 char restriction:</p>
<pre><code>123456789x123456789x123456789x123456789x123456789x123456789x123456789x123456789x12345678
</code></pre>
<p dir="auto">This is slightly different than your example result:</p>
<pre><code>...
123456789x123456789x123456789x123456789x123456789x123456789x123456789x123456789x12345678
"aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo",
"dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem",
...
</code></pre>
<p dir="auto">but I didn’t understand why you didn’t join more to that line</p>
<pre><code>...
123456789x123456789x123456789x123456789x123456789x123456789x123456789x123456789x12345678
"aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea", 
"rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ...",
</code></pre>
<h3><em>caveat emptor</em></h3>
<p dir="auto">This regex sequence shown here seemed to work for me, based on my understanding of your issue, and is published here to help you learn how to do this. I make no guarantees or warranties as to the functionality for you. You are responsible to save and backup all data before and after running this sequence.</p>
<h3>Additional Search/Replace Info</h3>
<p dir="auto"><em>Do you want regex search/replace help?  Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you.  All example text should be marked as literal text using the <code>&lt;/&gt;</code> toolbar button or manual <a href="https://community.notepad-plus-plus.org/topic/14262/how-to-markdown-code-on-this-forum/4">Markdown syntax</a>. To make <code>regex in red</code> (and so they keep their special characters like *), use backticks, like <code>`^.*?blah.*?\z`</code>. Screenshots can be pasted from the clipboard to your post using <code>Ctrl+V</code> to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have <strong>and</strong> the text you want to get from that data; include examples of things that <strong>should match</strong> and be transformed, <strong>and</strong> things that <strong>don’t match</strong> and should be left alone; show <strong>edge cases</strong> and make sure you examples are as <strong>varied</strong> as your real data.  Show the regex you already tried, <strong>and why</strong> you thought it should work; tell us what’s wrong with what you <strong>do</strong> get. Read the official <a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">NPP Searching / Regex docs</a> and the forum’s <a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regex-documentation">Regular Expression FAQ</a>. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/62750</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62750</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:24:28 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 16:20:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/62746">RegEX - How can I make automatic a new line (break) at x character</a>:</p>
<blockquote>
<p dir="auto">training</p>
</blockquote>
<p dir="auto">typo:  trailing!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/62749</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62749</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:20:07 GMT</pubDate></item><item><title><![CDATA[Reply to RegEX - How can I make automatic a  new line (break) at x character on Thu, 11 Feb 2021 16:16:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/venus642" aria-label="Profile: Venus642">@<bdi>Venus642</bdi></a></p>
<p dir="auto">Seems the solution would be to:</p>
<ul>
<li>
<p dir="auto">Remove leading <code>"</code> and trailing <code>",</code> from entire file (easy regex replacement)</p>
</li>
<li>
<p dir="auto">Join all lines (N++ menu command)</p>
</li>
<li>
<p dir="auto">Split lines so that maximum line length is 88 (N++ 7.9.3+ restores the Vertical Edge splitting capability, try the RC! – or this can be a not-super-easy regex replacement)</p>
</li>
<li>
<p dir="auto">Reapply the leading and training delimiters (another easy regex operation)</p>
</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/62746</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/62746</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Feb 2021 16:16:33 GMT</pubDate></item></channel></rss>