<?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[How do I replace strings of text while retaining numbers in middle of the line?]]></title><description><![CDATA[<p dir="auto">So, I am modding a game and have a .txt file in which I need to replace multiple, possibly hundreds of lines of this type :</p>
<p dir="auto"><strong>owns = 116</strong></p>
<p dir="auto">to this</p>
<p dir="auto"><strong>116 = { country_or_non_sovereign_subject_holds = ROOT }</strong></p>
<p dir="auto">The numbers after ‘owns =’ can be anything between 1-5000, so it can have 1 to 4 digits</p>
<p dir="auto">What would be the easiest way to replace all of the lines in this file?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/20837/how-do-i-replace-strings-of-text-while-retaining-numbers-in-middle-of-the-line</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 20:47:42 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/20837.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Mar 2021 10:56:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How do I replace strings of text while retaining numbers in middle of the line? on Fri, 12 Mar 2021 08:43:45 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<br />
You can replace strings of text while retaining numbers in the middle of the line using RegEx.<br />
Follow the steps:<br />
Open your document in N++.<br />
Go to the start of the document by clicking on ctrl+home.<br />
Open The Replace Dialogue Box (ctrl+h).<br />
Under search, mode Select regular expression.<br />
write the following in the fields.<br />
Find what:  (?i)(?s)owns = (\d{1,4})<br />
Replace with: $1 = { country_or_non_sovereign_subject_holds = ROOT }<br />
Click on Replace All.</p>
<p dir="auto">Description:<br />
(?s) enables dot matching newlines.<br />
(?i) makes match case insensitive.<br />
(owns) represents a literal string.<br />
(\d) (digit) matches any single digit (same as [0-9] ).<br />
{1,4} matches with a 1 to 4 digit number.<br />
$1 refers to the first match (in this case $1 will refer to the number i.e. 116).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63830</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63830</guid><dc:creator><![CDATA[Anandkumar Prajapati]]></dc:creator><pubDate>Fri, 12 Mar 2021 08:43:45 GMT</pubDate></item><item><title><![CDATA[Reply to How do I replace strings of text while retaining numbers in middle of the line? on Fri, 05 Mar 2021 12:35:22 GMT]]></title><description><![CDATA[<p dir="auto">Worked perfectly, thank you so much!!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63610</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63610</guid><dc:creator><![CDATA[Juuso Uu]]></dc:creator><pubDate>Fri, 05 Mar 2021 12:35:22 GMT</pubDate></item><item><title><![CDATA[Reply to How do I replace strings of text while retaining numbers in middle of the line? on Fri, 05 Mar 2021 11:43:51 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/21380">@Juuso-Uu</a></p>
<p dir="auto">A regular expression would be fine here. I assume the matching string is placed at the begining of a line. If this is not the case, please remove the <code>^</code> symbol from the Search expression.</p>
<pre><code class="language-z">Search: ^owns = (\d{1,4})
Replace: $1 = { country_or_non_sovereign_subject_holds = ROOT }
</code></pre>
<p dir="auto">Put the caret at the very beginning of the document, select just the <code>Regular Expression mode</code> and click on <code>Replace All</code>.</p>
<p dir="auto">Take care and have fun!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/63604</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/63604</guid><dc:creator><![CDATA[astrosofista]]></dc:creator><pubDate>Fri, 05 Mar 2021 11:43:51 GMT</pubDate></item></channel></rss>