<?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[Change a certain line in several documents with command/variables]]></title><description><![CDATA[<p dir="auto">Good evening together,</p>
<p dir="auto">i have multiple .json files where i want to replace a certain line in each.<br />
Line 6 in each file contains following content:</p>
<hr />
<p dir="auto">1.json (“edition”: 1,)<br />
2.json (“edition”: 2,)<br />
3.json (“edition”: 3,)<br />
4.json (“edition”: 4,)<br />
… etc.<br />
1000.json (“edition”: 1000,)</p>
<p dir="auto">change for each document the line 6 to:<br />
|<br />
|<br />
|<br />
V<br />
1.json ( “external_url” : “<a href="https://example.com/?token_id=1" rel="nofollow ugc">https://example.com/?token_id=1</a>”,)<br />
2.json ( “external_url” : “<a href="https://example.com/?token_id=2" rel="nofollow ugc">https://example.com/?token_id=2</a>”,)<br />
3.json ( “external_url” : “<a href="https://example.com/?token_id=3" rel="nofollow ugc">https://example.com/?token_id=3</a>”,)<br />
4.json ( “external_url” : “<a href="https://example.com/?token_id=4" rel="nofollow ugc">https://example.com/?token_id=4</a>”,)<br />
… etc.<br />
1000.json ( “external_url” : “<a href="https://example.com/?token_id=1000" rel="nofollow ugc">https://example.com/?token_id=1000</a>”,)</p>
<hr />
<p dir="auto">Is there any command to execute to change this line for each document?</p>
<p dir="auto">Many thanks in advance.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22810/change-a-certain-line-in-several-documents-with-command-variables</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 19:04:27 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22810.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Apr 2022 16:38:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Change a certain line in several documents with command/variables on Tue, 05 Apr 2022 16:57:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ivan-k-0" aria-label="Profile: ivan-k-0">@<bdi>ivan-k-0</bdi></a> said in <a href="/post/75763">Change a certain line in several documents with command/variables</a>:</p>
<blockquote>
<p dir="auto">Is there any command to execute to change this line for each document?</p>
</blockquote>
<p dir="auto">It’s called regular expression search and replace.</p>
<p dir="auto">Your method of describing your data is rather confusing.  I don’t know whether those digits really prefix each line, or if you are just numbering the lines, or numbering the documents that contain that as line#6.  Using the Template for Search/Replace questions mentioned below would have helped you communicate more clearly.</p>
<p dir="auto">But I can come up with a solution that is agnostic of that prefix anyway.</p>
<p dir="auto">If you want to replace <em>any</em> <code>json ("edition": ###,)</code> line with <code>json ( "external_url":"https://example.com/?token_id=###",)</code> then you can use<br />
FIND = <code>json \("edition": (\d+),\)</code><br />
REPLACE = <code>json \( "external_url":"https://example.com/?token_id=${1}",\)</code><br />
SEARCH MODE = Regular Expression</p>
<p dir="auto">If you have many such lines in the same file, but only want to replace the one on line 6, then change the FIND to <code>\A(?-s:^.*$\R){5}\K^json \("edition": (\d+),\)</code>, which looks for the beginning of the file and 5 lines, then restarts the match.</p>
<p dir="auto">If you allow other characters before the <code>json</code> prefix on line 6, you might have to tweak what comes after the <code>\K</code> to allow that.  I will leave that as an exercise for the reader; give it a try using the docs below, and if you cannot figure it out, ask for hints.</p>
<p dir="auto">-—</p>
<h3>Useful References</h3>
<ul>
<li><a href="https://community.notepad-plus-plus.org/topic/21965/please-read-before-posting">Please Read Before Posting</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/22022/template-for-search-replace-questions">Template for Search/Replace Questions</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regular-expressions-regex-documentation">FAQ: Where to find regular expressions (regex) documentation</a></li>
<li><a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">Notepad++ Online User Manual: Searching/Regex</a></li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/75769</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/75769</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 05 Apr 2022 16:57:53 GMT</pubDate></item></channel></rss>