<?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[Replace &amp; add specific parts&#x2F;symbols from a specific lines only]]></title><description><![CDATA[<p dir="auto">Hey guys,<br />
I’m having a HUGE .json file with 8,000+ lines but everything repeats with the following template.</p>
<pre><code>"water": {
    "DisplayName": "Water",
    "Skin": 0,
    "Image": "water.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 5000,
    "SellPrice": 0,
    "Currency": "eco"
  },
  "healingtea.advanced": {
    "DisplayName": "default",
    "Skin": 0,
    "Image": "healingtea.advanced.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 500,
    "SellPrice": 0,
    "Currency": "eco"
  },
</code></pre>
<p dir="auto">What I’m trying to do is adding a the same link before the <code>"imagename.png"</code> on every Image line as it’s shown in the current example</p>
<pre><code>"Image": "https://www.example.com/example2/healingtea.advanced.png"
</code></pre>
<p dir="auto">but also I have to replace the dot <code>.</code> with a dash <code>-</code> for example <code>healingtea-advanced.png</code><br />
without changing the dot before the “png” or the added link will break.</p>
<p dir="auto">Any help? For the URL part I think I have to use <code>^"Image": "</code> in the find field with a regex value mode and then in the replace field to add the <code>https://www.example.com/example2/</code><br />
Or will this add it in front of <code>^"Image": "</code> instead properly before the <code>imagename.png</code>?<br />
But first I have to somehow do the <code>.</code> with <code>-</code> replacing before I add the link and make it more hard for replacing, right?</p>
<p dir="auto">All of the lines I have to change starts with <code>^"Image": "</code> so they can be all searched properly and it’s maybe easy to exclude the <code>.</code> before the <code>png</code>  because it’s all the same again.</p>
<p dir="auto">I hope I explained everything properly, if you have ideas share them please. I’m completely new here and yesterday learned how to use <code>^</code> symbol and <code>Regex</code> myself to add the same <code>"</code> symbol in front of each Notepad++ line and <code>",</code> at the end but this is more complex for my brain, haha.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/26349/replace-add-specific-parts-symbols-from-a-specific-lines-only</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 09:43:39 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/26349.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 09 Nov 2024 09:45:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace &amp; add specific parts&#x2F;symbols from a specific lines only on Sat, 09 Nov 2024 18:03:44 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/32728">@flammable</a> and <strong>All</strong>,</p>
<p dir="auto">First, I would advice you to <strong>fully</strong> read this <strong>interesting</strong> <em>FAQ</em> post below, which explains to prefer the use of a <strong><code>JSON parser</code></strong> ( instead of <strong>regexes</strong> ) for such problems :</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/topic/25304/faq-parsing-and-editing-json-with-regex-is-a-bad-idea/1?lang=fr">https://community.notepad-plus-plus.org/topic/25304/faq-parsing-and-editing-json-with-regex-is-a-bad-idea/1?lang=fr</a></p>
<p dir="auto">Oh,…, by moving to your post, I just see the <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/26710">@mark-olson</a>’s reply which explains a <strong>straight</strong> solution, based on the <strong><code>JsonTools</code></strong> plugin ;-))</p>
<hr />
<p dir="auto">However, I also succeeded to find out a <strong>regex</strong> way to do it !</p>
<p dir="auto">So, given your <em>INPUT</em> text, below, in a <strong>new</strong> tab :</p>
<pre><code class="language-json">"water": {
    "DisplayName": "Water",
    "Skin": 0,
    "Image": "water.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 5000,
    "SellPrice": 0,
    "Currency": "eco"
  },
  "healingtea.advanced": {
    "DisplayName": "default",
    "Skin": 0,
    "Image": "healingtea.advanced.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 500,
    "SellPrice": 0,
    "Currency": "eco"
  },
</code></pre>
<ul>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto"><strong>Untick</strong> all <strong>box</strong> options</p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>(?-is)^\x20+"Image":\x20"\K</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>https://www.example\.com/example2/</code></strong></p>
</li>
<li>
<p dir="auto"><strong>Check</strong> the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Click, <strong>once</strong>, on the <strong><code>Replace All</code></strong> button ( <strong>NOT</strong> the <strong><code>Replace</code></strong>  button ! )</p>
</li>
</ul>
<p dir="auto">You should get this <em>OUTPUT</em> text :</p>
<pre><code class="language-json">"water": {
    "DisplayName": "Water",
    "Skin": 0,
    "Image": "https://www.example.com/example2/water.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 5000,
    "SellPrice": 0,
    "Currency": "eco"
  },
  "healingtea.advanced": {
    "DisplayName": "default",
    "Skin": 0,
    "Image": "https://www.example.com/example2/healingtea.advanced.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 500,
    "SellPrice": 0,
    "Currency": "eco"
  },
</code></pre>
<p dir="auto">Now with the following <strong>regex</strong> S/R, we’ll change any <strong>dot</strong> character, <strong>not</strong> followed by the string <strong><code>png",</code></strong> at <strong>end</strong> of line, with a <strong>dash</strong> char :</p>
<p dir="auto">SEARCH <strong><code>(?-si)(?:^\x20+"Image":\x20"https://www.example.com/example2/|(?!\A)\G).*?\K\.(?!png",$)</code></strong></p>
<p dir="auto">REPLACE <strong><code>-</code></strong></p>
<p dir="auto">Just follow, <strong>exactly</strong>, the same <strong>other</strong> points of the <strong>previous</strong> S/R !</p>
<p dir="auto">You should get your <strong>expected</strong> <em>OUTPUT</em> text :</p>
<pre><code class="language-json">"water": {
    "DisplayName": "Water",
    "Skin": 0,
    "Image": "https://www.example.com/example2/water.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 5000,
    "SellPrice": 0,
    "Currency": "eco"
  },
  "healingtea.advanced": {
    "DisplayName": "default",
    "Skin": 0,
    "Image": "https://www.example.com/example2/healingtea-advanced.png",
    "DefaultAmount": 1,
    "BlockAmountChange": false,
    "BuyPrice": 500,
    "SellPrice": 0,
    "Currency": "eco"
  },
</code></pre>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/97777</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/97777</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 09 Nov 2024 18:03:44 GMT</pubDate></item><item><title><![CDATA[Reply to Replace &amp; add specific parts&#x2F;symbols from a specific lines only on Sat, 09 Nov 2024 17:50:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/32728">@Flammable</a></p>
<p dir="auto">This is the kind of job that you don’t want to use regular expressions for; <a href="https://community.notepad-plus-plus.org/topic/25304/faq-parsing-and-editing-json-with-regex-is-a-bad-idea/2">JSON can be very hard to parse with regex</a>. Use a JSON parser instead.</p>
<p dir="auto">If I understand your goal correctly, your JSON document is an object that has many instances of the following:</p>
<pre><code>    "this.is_the.key": {
        "BlockAmountChange": (true or false),
        "BuyPrice": (integer),
        "Currency": (text),
        "DefaultAmount": (integer),
        "DisplayName": (text),
        "Image": (text),
        "SellPrice": (integer),
        "Skin": (integer)
    }
</code></pre>
<p dir="auto">and you want to modify every one of these objects to the following:</p>
<pre><code>    "this.is_the.key": {
        "BlockAmountChange": (true or false),
        "BuyPrice": (integer),
        "Currency": (text),
        "DefaultAmount": (integer),
        "DisplayName": (text),
        "Image": "https://www.example.com/example2/this-is_the-key.png",
        "SellPrice": (integer),
        "Skin": (integer)
    }
</code></pre>
<p dir="auto">There are many ways to do this, including with scripting plugins like <a href="https://github.com/bruderstein/PythonScript/releases" rel="nofollow ugc">PythonScript</a>. I’m going to demonstrate how to do this with the <a href="https://github.com/molsonkiko/JsonToolsNppPlugin" rel="nofollow ugc">JsonTools plugin</a> using <a href="https://github.com/molsonkiko/JsonToolsNppPlugin/blob/main/docs/RemesPath.md" rel="nofollow ugc">RemesPath</a>. If you need to automate this procedure, I recommend learning Python, and using the steps below as a starting point for your Python script that does this.</p>
<ol>
<li>Copy the text of your file into a new buffer so that you can compare the result to the original</li>
<li>Open the tree view in JsonTools in your new buffer</li>
<li>Paste the following query in the text box at the top of the tree view<pre><code>for x = keys(@);
at(@, x).Image = `https://www.example.com/example2/` + s_sub(x, `.`, `-`) + `.png`
</code></pre>
</li>
<li>Click the <code>Submit query</code> button; this will change every <code>Image</code> field</li>
<li>You can use ComparePlus to compare the result with the original and make sure it’s to your liking.</li>
</ol>
<p dir="auto">I tested this query with the following <strong>START</strong> JSON:</p>
<pre><code class="language-json">{
    "3kkQI.k67920": {
        "BlockAmountChange": false,
        "BuyPrice": -708951,
        "Currency": "DBg0",
        "DefaultAmount": -618002,
        "DisplayName": "default",
        "Image": "PAC",
        "SellPrice": -191929,
        "Skin": 439298
    },
    "ruHOa": {
        "BlockAmountChange": false,
        "BuyPrice": 800735,
        "Currency": "7",
        "DefaultAmount": 92053,
        "DisplayName": "8G",
        "Image": "cDf.Sdw",
        "SellPrice": 434145,
        "Skin": -127422
    },
    "Eup8FI8t.bvBR_JZcEv.YHBfpk": {
        "BlockAmountChange": true,
        "BuyPrice": 74371,
        "Currency": "KD",
        "DefaultAmount": 687624,
        "DisplayName": "I8v",
        "Image": "I3JGDMP.QUxCfddTP",
        "SellPrice": 94973,
        "Skin": -40263
    },
    "water": {
        "DisplayName": "Water",
        "Skin": 0,
        "Image": "water.png",
        "DefaultAmount": 1,
        "BlockAmountChange": false,
        "BuyPrice": 5000,
        "SellPrice": 0,
        "Currency": "eco"
    },
    "healingtea.advanced": {
        "DisplayName": "default",
        "Skin": 0,
        "Image": "healingtea.advanced.png",
        "DefaultAmount": 1,
        "BlockAmountChange": false,
        "BuyPrice": 500,
        "SellPrice": 0,
        "Currency": "eco"
    }
}
</code></pre>
<p dir="auto">and got this <strong>END</strong> JSON:</p>
<pre><code class="language-json">{
    "3kkQI.k67920": {
        "BlockAmountChange": false,
        "BuyPrice": -708951,
        "Currency": "DBg0",
        "DefaultAmount": -618002,
        "DisplayName": "default",
        "Image": "https://www.example.com/example2/3kkQI-k67920.png",
        "SellPrice": -191929,
        "Skin": 439298
    },
    "ruHOa": {
        "BlockAmountChange": false,
        "BuyPrice": 800735,
        "Currency": "7",
        "DefaultAmount": 92053,
        "DisplayName": "8G",
        "Image": "https://www.example.com/example2/ruHOa.png",
        "SellPrice": 434145,
        "Skin": -127422
    },
    "Eup8FI8t.bvBR_JZcEv.YHBfpk": {
        "BlockAmountChange": true,
        "BuyPrice": 74371,
        "Currency": "KD",
        "DefaultAmount": 687624,
        "DisplayName": "I8v",
        "Image": "https://www.example.com/example2/Eup8FI8t-bvBR_JZcEv-YHBfpk.png",
        "SellPrice": 94973,
        "Skin": -40263
    },
    "water": {
        "DisplayName": "Water",
        "Skin": 0,
        "Image": "https://www.example.com/example2/water.png",
        "DefaultAmount": 1,
        "BlockAmountChange": false,
        "BuyPrice": 5000,
        "SellPrice": 0,
        "Currency": "eco"
    },
    "healingtea.advanced": {
        "DisplayName": "default",
        "Skin": 0,
        "Image": "https://www.example.com/example2/healingtea-advanced.png",
        "DefaultAmount": 1,
        "BlockAmountChange": false,
        "BuyPrice": 500,
        "SellPrice": 0,
        "Currency": "eco"
    }
}
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/97775</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/97775</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Sat, 09 Nov 2024 17:50:20 GMT</pubDate></item></channel></rss>