<?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[search and replace: replace 66 terms]]></title><description><![CDATA[<p dir="auto">Hi, I have hundreds of articles in Chinese (unicode characters) full of Biblical references. I need to replace the Chinese reference to English. An example would be:</p>
<p dir="auto">(創1:1) need to replace “(創” with "(Gen "<br />
(出2:2) need to replace  “(出” with  "(Exo "<br />
etc.</p>
<p dir="auto">As there are 66 books in the Bible, I need to do the search and replace 66 times.I tried recording a macro, but I kept making mistakes, and found it very difficult to get it right.</p>
<p dir="auto">I understand that this may be possible by using regular expressions, but I have diffculties in consturcting the right syntax.</p>
<p dir="auto">Can any one show me how this can be done?</p>
<p dir="auto">Doing a search for 66 items in one go may be too much, and I am prepared to break it do down to smaller chunks.</p>
<p dir="auto">Thanks in advace for any constructive suggestions.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/16092/search-and-replace-replace-66-terms</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 09:25:34 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/16092.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 26 Jul 2018 20:43:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to search and replace: replace 66 terms on Mon, 30 Jul 2018 09:14:42 GMT]]></title><description><![CDATA[<p dir="auto">Just for clarification to my last post, I mean replacing Chinese numerials with arabic numerials, just in case someone is wondering :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33821</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33821</guid><dc:creator><![CDATA[Michael Hsu]]></dc:creator><pubDate>Mon, 30 Jul 2018 09:14:42 GMT</pubDate></item><item><title><![CDATA[Reply to search and replace: replace 66 terms on Mon, 30 Jul 2018 09:06:20 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> &amp; <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a></p>
<p dir="auto">Wow, you guys are amazing.</p>
<p dir="auto">Thanks very much for the assistance.</p>
<p dir="auto">The next task is to replace the Chinese numbering system with Roman numerials. Using two lists to generate the S/R syntax is certainly most helping.</p>
<p dir="auto">Once again, thanks a million</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33820</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33820</guid><dc:creator><![CDATA[Michael Hsu]]></dc:creator><pubDate>Mon, 30 Jul 2018 09:06:20 GMT</pubDate></item><item><title><![CDATA[Reply to search and replace: replace 66 terms on Fri, 27 Jul 2018 18:56:46 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-hsu" aria-label="Profile: michael-hsu">@<bdi>michael-hsu</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a>,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a> :</p>
<p dir="auto">Aaaah ! I wish I could have been a <strong>magician</strong> and produced a regex which could generate an <strong>automatic numbering</strong> list, but, unfortunately, I’m <strong>not</strong> :-(( Don’t be sad : It’s just one of the advantages of <strong>scripting</strong> languages as <strong>Python</strong> and <strong>Lua</strong> :-))</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-hsu" aria-label="Profile: michael-hsu">@<bdi>michael-hsu</bdi></a></p>
<p dir="auto">Indeed, regexes are no <strong>good</strong> for calculus and operations as <strong><code>i+=1</code></strong>, are rather <strong>impossible</strong> to produce. So, I <strong>preceded</strong> your list of your <strong>English</strong> words, with a list of <strong>numbers</strong>, which can be generated, as <strong>Scott</strong> suggested, with the command <strong>Edit &gt; Column Editor…</strong></p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33783</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33783</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 27 Jul 2018 18:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to search and replace: replace 66 terms on Fri, 27 Jul 2018 18:25:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> ,</p>
<p dir="auto">So let’s try RegexBuddy on one of your regexes from an earlier post in this thread, this time with links!:</p>
<p dir="auto">FIND <code>(\(創)|(\(出)</code></p>
<ul>
<li><a href="http://www.regular-expressions.info/alternation.html" rel="nofollow ugc">Match this alternative (attempting the next alternative only if this one fails)</a> <code>(\(創)</code>
<ul>
<li><a href="http://www.regular-expressions.info/brackets.html" rel="nofollow ugc">Match the regex below and capture its match into backreference number 1</a> <code>(\(創)</code>
<ul>
<li><a href="http://www.regular-expressions.info/characters.html#special" rel="nofollow ugc">Match the opening parenthesis character</a> <code>\(</code></li>
<li><a href="http://www.regular-expressions.info/characters.html" rel="nofollow ugc">Match the character “創” literally</a> <code>創</code></li>
</ul>
</li>
</ul>
</li>
<li><a href="http://www.regular-expressions.info/alternation.html" rel="nofollow ugc">Or match this alternative (the entire match attempt fails if this one fails to match)</a> <code>(\(出)</code>
<ul>
<li><a href="http://www.regular-expressions.info/brackets.html" rel="nofollow ugc">Match the regex below and capture its match into backreference number 2</a> <code>(\(出)</code>
<ul>
<li><a href="http://www.regular-expressions.info/characters.html#special" rel="nofollow ugc">Match the opening parenthesis character</a> <code>\(</code></li>
<li><a href="http://www.regular-expressions.info/characters.html" rel="nofollow ugc">Match the character “出” literally</a> <code>出</code></li>
</ul>
</li>
</ul>
</li>
</ul>
<p dir="auto">REPLACE <code>(?1\(Gen)(?2\(Ex)</code></p>
<ul>
<li><a href="http://www.regular-expressions.info/replaceconditional.html#boost" rel="nofollow ugc">Check whether capturing group number 1 was matched</a> <code>(?1\(Gen)</code>
<ul>
<li><a href="http://www.regular-expressions.info/replaceconditional.html#boost" rel="nofollow ugc">If the group was matched then insert the following</a> <code>\(Gen</code>
<ul>
<li><a href="http://www.regular-expressions.info/replacecharacters.html" rel="nofollow ugc">Insert an opening parenthesis</a> <code>\(</code></li>
<li><a href="http://www.regular-expressions.info/characters.html" rel="nofollow ugc">Insert the character string “Gen” literally</a> <code>Gen</code></li>
</ul>
</li>
</ul>
</li>
<li><a href="http://www.regular-expressions.info/replaceconditional.html#boost" rel="nofollow ugc">Check whether capturing group number 2 was matched</a> <code>(?2\(Ex)</code>
<ul>
<li><a href="http://www.regular-expressions.info/replaceconditional.html#boost" rel="nofollow ugc">If the group was matched then insert the following</a> <code>\(Ex</code>
<ul>
<li><a href="http://www.regular-expressions.info/replacecharacters.html" rel="nofollow ugc">Insert an opening parenthesis</a> <code>\(</code></li>
<li><a href="http://www.regular-expressions.info/characters.html" rel="nofollow ugc">Insert the character string “Ex” literally</a> <code>Ex</code></li>
</ul>
</li>
</ul>
</li>
</ul>
<p dir="auto">Created with <a href="http://www.regexbuddy.com/" rel="nofollow ugc">RegexBuddy</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/33782</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33782</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Fri, 27 Jul 2018 18:25:43 GMT</pubDate></item><item><title><![CDATA[Reply to search and replace: replace 66 terms on Fri, 27 Jul 2018 18:19:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">In the interim between your last two posts, I was wondering how you were going to get the <em>numbers</em> into the replace expression.  I thought some new regex trick was coming, but no, the numbers are part of the data, they don’t get created by the regex.  :-)</p>
<p dir="auto">However, if all one had was a list of the un-numbered replacement values, one could easily use Notepad++'s <strong>Edit</strong> (menu) -&gt; <strong>Column Editor…</strong> to add the numbers before running the regex to create the regex.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33781</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33781</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Fri, 27 Jul 2018 18:19:04 GMT</pubDate></item><item><title><![CDATA[Reply to search and replace: replace 66 terms on Fri, 27 Jul 2018 18:00:55 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-hsu" aria-label="Profile: michael-hsu">@<bdi>michael-hsu</bdi></a>, and <strong>All</strong></p>
<p dir="auto"><strong>Glad</strong> that everything went <strong>fine</strong> :-)) I just noticed that I did <strong>not</strong> include the <strong>opening</strong> parenthesis <strong><code>(</code></strong> in my regexes. And I guess that your <strong>Chinese</strong> characters may occur, in your file, <strong>without</strong> parentheses, too ! In that case, of course, the regexes become, for instance :</p>
<p dir="auto">SEARCH <strong><code>(\(創)|(\(出)</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1\(Gen)(?2\(Ex)</code></strong></p>
<hr />
<p dir="auto">Now, in the <strong>last</strong> point of my <strong>previous</strong> post, I just wanted to point out that, from your <strong>complete</strong> list of <strong><code>66</code></strong> <strong>Chinese</strong> chars and the <strong><code>66</code></strong> <strong>English</strong> words, it’s possible to <strong>generate</strong> your <strong>big</strong> search / replace regexes with <strong>specific</strong> regexes. Here is, below, an <strong>example</strong> with the first <strong><code>7</code></strong> items of your list, but it would works for <strong>any</strong> number of items. Actually, not exactly, because the total <strong>size</strong> of the <strong>search</strong> and <strong>replace</strong> zones must not exceed <strong><code>2046</code></strong> characters !</p>
<p dir="auto">So from the list :</p>
<pre><code class="language-diff">創
出
利
民
申
書
士
</code></pre>
<p dir="auto">the regex :</p>
<p dir="auto">SEARCH <strong><code>(\w)\R(\R)?</code></strong></p>
<p dir="auto">REPLACE <strong><code>\(\\\($1\)(?2:|)</code></strong></p>
<p dir="auto">would produce your <strong>final SEARCH</strong> regex :</p>
<pre><code class="language-diff">(\(創)|(\(出)|(\(利)|(\(民)|(\(申)|(\(書)|(\(士)
</code></pre>
<p dir="auto">Voilà !</p>
<p dir="auto">Similarly, with that given list :</p>
<pre><code class="language-diff">1Gen
2Ex
3Lev
4Num
5Deut
6Jos
7Jdg
</code></pre>
<p dir="auto">The following regex :</p>
<p dir="auto">SEARCH <strong><code>(\d+)(\w+)\R</code></strong></p>
<p dir="auto">REPLACE <strong><code>\(?$1\\\($2\)</code></strong></p>
<p dir="auto">would generate your <strong>final REPLACEMENT</strong> regex</p>
<pre><code class="language-diff">(?1\(Gen)(?2\(Ex)(?3\(Lev)(?4\(Num)(?5\(Deut)(?6\(Jos)(?7\(Jdg)
</code></pre>
<p dir="auto">Whaoou ! And process would be <strong>identical</strong> for your <strong><code>66</code></strong> items ;-))</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">Thus, from your <strong>original</strong> text :</p>
<pre><code class="language-diff">(創1:1)
(出2:2)
(利3:3)
(民4:4)
(申5:5)
(書6:6)
(士7:7)
</code></pre>
<p dir="auto">and the two <strong>generated</strong> regexes, below :</p>
<p dir="auto">SEARCH <strong><code>(\(創)|(\(出)|(\(利)|(\(民)|(\(申)|(\(書)|(\(士)</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1\(Gen)(?2\(Ex)(?3\(Lev)(?4\(Num)(?5\(Deut)(?6\(Jos)(?7\(Jdg)</code></strong></p>
<p dir="auto">It would give your <strong>expected</strong> list !</p>
<pre><code class="language-diff">(Gen1:1)
(Ex2:2)
(Lev3:3)
(Num4:4)
(Deut5:5)
(Jos6:6)
(Jdg7:7)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/33778</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33778</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 27 Jul 2018 18:00:55 GMT</pubDate></item><item><title><![CDATA[Reply to search and replace: replace 66 terms on Fri, 27 Jul 2018 15:12:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
<p dir="auto">Thank you very much for your prompt and helpful reply.</p>
<p dir="auto">I managed to construct the required S/R with your assistance.</p>
<p dir="auto">For the record, I did two S&amp;R, one for the Old Testament references, and another one for the New Testament.</p>
<p dir="auto">Search: ((創)|((出)|((利)|((民)|((申)|((書)|((士)|((得)|((撒上)|((撒下)|((王上)|((王下)|((代上)|((代下)|((拉)|((尼)|((斯)|((伯)|((詩)|((箴)|((傳)|((歌)|((賽)|((耶)|((哀)|((結)|((但)|((何)|((珥)|((摩)|((俄)|((拿)|((彌)|((鴻)|((哈)|((番)|((該)|((亞)|((瑪)</p>
<p dir="auto">Replace: (?1(Gen)(?2(Ex)(?3(Lev)(?4(Num)(?5(Deut)(?6(Jos)(?7(Jdg)(?8(Ruth)(?9(1 Sam)(?10(2 Sam)(?11(1 Kgs)(?12(2 Kgs)(?13(1 Ch)(?14(2 Ch)(?15(Ezr)(?16(Neh)(?17(Est)(?18(Job)(?19(Ps)(?20(Prov)(?21(Ecc)(?22(Song)(?23(Isa)(?24(Jer)(?25(Lam)(?26(Ezk)(?27(Dan)(?28(Hos)(?29(Joel)(?30(Amos)(?31(Obad)(?32(Jon)(?33(Mic)(?34(Nah)(?35(Hab)(?36(Zep)(?37(Hag)(?38(Zec)(?39(Mal)\x20</p>
<p dir="auto">Search: ((啟)|((猶)|((約參)|((約貳)|((約壹)|((彼後)|((彼前)|((雅)|((來)|((門)|((多)|((提後)|((提前)|((帖後)|((帖前)|((西)|((腓)|((弗)|((加)|((林後)|((林前)|((羅)|((徒)|((約)|((路)|((可)|((太)|((啓)</p>
<p dir="auto">Replace: (?1(Rev)(?2(Jud)(?3(3 Jn)(?4(2 Jn)(?5(1 Jn)(?6(2 Pet)(?7(1 Pet)(?8(Jas)(?9(Heb)(?10(Phm)(?11(Tit)(?12(2 Tim)(?13(1 Tim)(?14(2 Th)(?15(1 Th)(?16(Col)(?17(Phil)(?18(Eph)(?19(Gal)(?20(2 Cor)(?21(1 Cor)(?22(Rom)(?23(Act)(?24(Jn)(?25(Lk)(?26(Mk)(?27(Mat)(?28(Rev)\x20</p>
<p dir="auto">Just one more question: can you clarify what you meant by the last sentence? How would I generate a regex with another regex?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33775</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33775</guid><dc:creator><![CDATA[Michael Hsu]]></dc:creator><pubDate>Fri, 27 Jul 2018 15:12:23 GMT</pubDate></item><item><title><![CDATA[Reply to search and replace: replace 66 terms on Fri, 27 Jul 2018 08:15:02 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/michael-hsu" aria-label="Profile: michael-hsu">@<bdi>michael-hsu</bdi></a>, and <strong>All</strong></p>
<p dir="auto">I think that changing these <strong>66</strong> items, in <strong>one</strong> go, is quite <strong>possible</strong> :-)) I just give you the <strong>general</strong> rule to apply :</p>
<ul>
<li>
<p dir="auto">Your <strong>SEARCH</strong> regex will be simply composed of the list of all your <strong>Chinese</strong> characters, surrounded with <strong>parentheses</strong>, in order to define a <strong>capturing group</strong> ( <strong><code>1</code></strong>, <strong><code>2</code></strong>, and so on ), and separated with the <strong><code>|</code></strong> symbol to create multiples <strong>alternatives</strong>, tested, <strong>one</strong> after <strong>another</strong>, evaluated from the <strong>leftmost</strong> one to the <strong>rightmost</strong> one</p>
</li>
<li>
<p dir="auto">Your <strong>REPLACE</strong> regex will be a <strong>non-ordered</strong> list of <strong>several conditional</strong> replacements, of the form <strong><code>(?#ABCD)</code></strong>, which means that, if the group <strong><code>#</code></strong> is <strong>matched</strong>, in the <strong>search</strong>  regex, it will be <strong>replaced</strong> with the <strong><code>ABCD</code></strong> text. At the <strong>end</strong> of all these syntaxes, just add the <strong><code>\x20</code></strong> syntax which is just… a <strong>space</strong> char</p>
</li>
</ul>
<p dir="auto">So assuming your text</p>
<pre><code class="language-diff">(創1:1)
(出2:2)
</code></pre>
<p dir="auto">SEARCH <strong><code>(創)|(出)</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1Gen)(?2Exo)\x20</code></strong></p>
<p dir="auto">Of course, in the <strong>Replace</strong> dialog, the <strong><code>Regular expression</code></strong> search mode must be <strong>selected</strong> and, preferably, the <strong><code>Wrap around</code></strong> option will be <strong>ticked</strong>. Then, after clicking on the <strong><code>Replace All</code></strong> button , you should obtain :</p>
<pre><code class="language-diff">(Gen 1:1)
(Exo 2:2)
</code></pre>
<hr />
<p dir="auto">So the <strong>general</strong> syntax is :</p>
<p dir="auto">SEARCH <strong><code>(Search_1)|(Search_2)|(Search_3)|..............|(Search_n)</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1Replacement_1)(?2Replacement_2)(?3Replacement_3)...............(?nReplacement_n)</code></strong></p>
<hr />
<p dir="auto">BTW, if you have a list of your <strong><code>66</code> Chinese</strong> items and a <strong>second</strong> list of the <strong><code>66</code> English</strong> items, I could, first, generate the <strong>totality</strong> of your <strong>regex</strong> S/R…with an other <strong>regex</strong> !!</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33769</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33769</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 27 Jul 2018 08:15:02 GMT</pubDate></item></channel></rss>