<?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[Find and Replace with RegEx help]]></title><description><![CDATA[<p dir="auto">EDIT: The forum software keeps truncating some of the code examples for some reason. It shows up fine in the preview pane, but once submitting, it’s gone. I don’t know how to get around this, so <a href="https://i.imgur.com/RLgQNfD.png" rel="nofollow ugc">here’s a screenshot of what things should look like</a>.</p>
<p dir="auto">I can’t wrap my head around this. I’m trying to do a complicated find and replace on a MediaWiki source file. I’d like to convert a page full of image links in this format:</p>
<pre><code>&lsqb;&lsqb;File:ImageNameRare.png|50px|link=Page Name&rsqb;&rsqb;
</code></pre>
<p dir="auto">to this format:</p>
<pre><code>{{ItemPic|Page Name|3||50px}}
</code></pre>
<p dir="auto">Here are a couple of things to note. In the original format, all image names will have the suffixes of Basic, Common, Uncommon, Rare, SuperRare, or Legendary. These would need to be converted to numbers from 0 to 5, respectively. You can see where the “Rare” suffix was converted to a 3. Also, the Page Name would need to be preserved from the original to the new format. Nothing else needs to be preserved. The ImageName.png is no longer necessary and all links will feature 50px images, so that won’t change.</p>
<p dir="auto">Finally, there are instances on the page of this file format that I do <strong>not</strong> want to replace. In these instances, the link= will be blank, as in this example:</p>
<pre><code>&lsqb;&lsqb;File:ImageName.png|50px|link=&rsqb;&rsqb;
</code></pre>
<p dir="auto">If <em>link=</em> is followed immediately by two end brackets then the line should be ignored.</p>
<p dir="auto">I really hate asking this question here because I feel it’s outside of the scope of these forums, but I don’t know where else to ask. Can anybody help with this? I have over 3000 instances of this text in the document that need to be replaced, so doing it by hand is completely out of the question.</p>
<p dir="auto">Thank you.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/14979/find-and-replace-with-regex-help</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 22:41:15 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/14979.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Dec 2017 00:57:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Find and Replace with RegEx help on Wed, 27 Dec 2017 00:39:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a> said:</p>
<blockquote>
<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">I was close, wasn’t I? :-D</p>
<p dir="auto">thx for the detailed information and improvements - always a pleasure :-)</p>
<p dir="auto">Cheers<br />
Claudia</p>
</blockquote>
<p dir="auto">Yours was the one I used before guy038 made his post and it worked perfectly, so I would say you were more than close. :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28987</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28987</guid><dc:creator><![CDATA[Ksomeone Msomeone]]></dc:creator><pubDate>Wed, 27 Dec 2017 00:39:59 GMT</pubDate></item><item><title><![CDATA[Reply to Find and Replace with RegEx help on Tue, 26 Dec 2017 23:00:08 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">I was close, wasn’t I? :-D</p>
<p dir="auto">thx for the detailed information and improvements - always a pleasure :-)</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28982</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28982</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 26 Dec 2017 23:00:08 GMT</pubDate></item><item><title><![CDATA[Reply to Find and Replace with RegEx help on Tue, 26 Dec 2017 22:43:38 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> said:</p>
<blockquote>
<p dir="auto">Regarding your <strong>initial</strong> text :</p>
<pre><code class="language-diff">&lsqb;&lsqb;File:ImageNameRare.png|50px|link=Page Name&rsqb;&rsqb;
</code></pre>
<ul>
<li>
<p dir="auto">I assumed that you don’t care about the first part <strong><code>File:ImageName</code></strong>, after the two <strong>opening square</strong> brackets</p>
</li>
<li>
<p dir="auto">I think that you don’t care, also, about the second part <strong><code>.png|50px|link</code></strong>, coming <strong>after</strong> the suffixes <strong><code>Basic</code></strong>, <strong><code>Rare</code></strong> or else !</p>
</li>
<li>
<p dir="auto">And, as you said, only the <strong><code>Page Name</code></strong>, after the <strong><code>=</code></strong> sign  and before the two <strong>ending square</strong> brackets, must be rewritten, during the <strong>replacement</strong> process</p>
</li>
<li>
<p dir="auto">Finally, if the line does <strong>not</strong> contain any <strong><code>Page name</code></strong>, and ends as <strong><code>link=&rsqb;&rsqb;</code></strong>, <strong>NO</strong> replacement must occur !</p>
</li>
</ul>
<hr />
<p dir="auto">Now, regarding the <strong>final expected</strong> text :</p>
<pre><code class="language-diff">{{ItemPic|Page Name|3||50px}}
</code></pre>
<ul>
<li>
<p dir="auto">I assumed that the part <strong><code>ItemPic|</code></strong> is a simple <strong>literal</strong> string</p>
</li>
<li>
<p dir="auto">Then, the <strong><code>Page name</code></strong>, memorized from the <strong>initial</strong> text, must be rewritten, followed by a <strong><code>|</code></strong> symbol</p>
</li>
<li>
<p dir="auto">Now, as you explained, it should rewrite a single <strong>digit</strong>, from <strong><code>0</code></strong> to <strong><code>5</code></strong>, according to the <strong><code>6</code></strong> corresponding states <strong>Basic</strong> , <strong>Common</strong>, <strong>Uncommon</strong> , <strong>Rare</strong> , <strong>SuperRare</strong> and <strong>Legendary</strong></p>
</li>
<li>
<p dir="auto">Finally, we just write the <strong>literal</strong> string <strong><code>||50px</code></strong>, after the <strong>one-digit</strong>, as you said that <strong>all</strong> images are <strong><code>50px</code></strong>, anyway !</p>
</li>
<li>
<p dir="auto">Note that if the line ends with <strong><code>link=&rsqb;&rsqb;</code></strong>, after replacement, it will be <strong>unchanged</strong>, and keep the <strong>square</strong> brackets, instead of the <strong>curly braces</strong> !</p>
</li>
</ul>
</blockquote>
<p dir="auto">You got it exactly right. Thank you for the detailed explanation. I’ll definitely be bookmarking this post so that I can come back and read this again if I need help with something like this.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28980</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28980</guid><dc:creator><![CDATA[Ksomeone Msomeone]]></dc:creator><pubDate>Tue, 26 Dec 2017 22:43:38 GMT</pubDate></item><item><title><![CDATA[Reply to Find and Replace with RegEx help on Wed, 27 Dec 2017 04:05:42 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ksomeone-msomeone" aria-label="Profile: ksomeone-msomeone">@<bdi>ksomeone-msomeone</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: claudia-frank">@<bdi>claudia-frank</bdi></a> and <strong>All</strong></p>
<p dir="auto"><strong>Interesting</strong> S/R, indeed ! BTW, this post is quite <strong>long</strong>, so just have a <strong>drink</strong> or read it, in <strong>several</strong> times ;-))</p>
<p dir="auto"><strong>Claudia</strong>, you’ve already explained <strong>fully</strong> these regexes, while I was thinking about a solution, too ! Anyway, <a class="plugin-mentions-user plugin-mentions-a" href="/user/ksomeone-msomeone" aria-label="Profile: ksomeone-msomeone">@<bdi>ksomeone-msomeone</bdi></a>, will also get <strong>additional</strong> information from my post !</p>
<hr />
<p dir="auto">Regarding your <strong>initial</strong> text :</p>
<pre><code class="language-diff">&lsqb;&lsqb;File:ImageNameRare.png|50px|link=Page Name&rsqb;&rsqb;
</code></pre>
<ul>
<li>
<p dir="auto">I assumed that you don’t care about the first part <strong><code>File:ImageName</code></strong>, after the two <strong>opening square</strong> brackets</p>
</li>
<li>
<p dir="auto">I think that you don’t care, also, about the second part <strong><code>.png|50px|link</code></strong>, coming <strong>after</strong> the suffixes <strong><code>Basic</code></strong>, <strong><code>Rare</code></strong> or else !</p>
</li>
<li>
<p dir="auto">And, as you said, only the <strong><code>Page Name</code></strong>, after the <strong><code>=</code></strong> sign  and before the two <strong>ending square</strong> brackets, must be rewritten, during the <strong>replacement</strong> process</p>
</li>
<li>
<p dir="auto">Finally, if the line does <strong>not</strong> contain any <strong><code>Page name</code></strong>, and ends as <strong><code>link=&rsqb;&rsqb;</code></strong>, <strong>NO</strong> replacement must occur !</p>
</li>
</ul>
<hr />
<p dir="auto">Now, regarding the <strong>final expected</strong> text :</p>
<pre><code class="language-diff">{{ItemPic|Page Name|3||50px}}
</code></pre>
<ul>
<li>
<p dir="auto">I assumed that the part <strong><code>ItemPic|</code></strong> is a simple <strong>literal</strong> string</p>
</li>
<li>
<p dir="auto">Then, the <strong><code>Page name</code></strong>, memorized from the <strong>initial</strong> text, must be rewritten, followed by a <strong><code>|</code></strong> symbol</p>
</li>
<li>
<p dir="auto">Now, as you explained, it should rewrite a single <strong>digit</strong>, from <strong><code>0</code></strong> to <strong><code>5</code></strong>, according to the <strong><code>6</code></strong> corresponding states <strong>Basic</strong> , <strong>Common</strong>, <strong>Uncommon</strong> , <strong>Rare</strong> , <strong>SuperRare</strong> and <strong>Legendary</strong></p>
</li>
<li>
<p dir="auto">Finally, we just write the <strong>literal</strong> string <strong><code>||50px</code></strong>, after the <strong>one-digit</strong>, as you said that <strong>all</strong> images are <strong><code>50px</code></strong>, anyway !</p>
</li>
<li>
<p dir="auto">Note that if the line ends with <strong><code>link=&rsqb;&rsqb;</code></strong>, after replacement, it will be <strong>unchanged</strong>, and keep the <strong>square</strong> brackets, instead of the <strong>curly braces</strong> !</p>
</li>
</ul>
<hr />
<p dir="auto">So, from the <strong>hypotheses</strong>, above, I built the following <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-si)\[\[.+?(?:(Basic)|(Uncommon)|(Common)|(SuperRare)|(Rare)|(Legendary)).+=(.+)\]\]</code></strong></p>
<p dir="auto">REPLACE <strong><code>{{ItemPic|$7|(?{1}0)(?{2}2)(?{3}1)(?{4}4)(?{5}3)(?{6}5)||50px}}</code></strong></p>
<p dir="auto">And, given the <strong>Claudia</strong>’s example text, below :</p>
<pre><code class="language-diff">&lsqb;&lsqb;File:ImageNameBasic.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameCommon.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameUncommon.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameRare.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameSuperRare.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameLegendary.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageName|50px|link=&rsqb;&rsqb;
</code></pre>
<p dir="auto"><strong>after</strong> performing this S/R, this text turns into :</p>
<pre><code class="language-diff">{{ItemPic|Page Name|0||50px}}
{{ItemPic|Page Name|1||50px}}
{{ItemPic|Page Name|2||50px}}
{{ItemPic|Page Name|3||50px}}
{{ItemPic|Page Name|4||50px}}
{{ItemPic|Page Name|5||50px}}
&lsqb;&lsqb;File:ImageName|50px|link=&rsqb;&rsqb;
</code></pre>
<hr />
<p dir="auto">Before explaining this <strong>regex</strong> S/R, it should be useful to remember some <strong>rules</strong> !</p>
<ul>
<li>
<p dir="auto">When you search, either, for <strong>two</strong> words, whose one is <strong>part</strong> of the second, as for example <strong>Rare</strong> and <strong>SuperRare</strong>, the <strong>correct</strong> syntax of the <strong>alternative</strong> is : <strong><code>SuperRare|Rare</code></strong> with the longest word as the <strong>first</strong> branch ( and <strong>NOT</strong>  <strong><code>Rare|SuperRare</code></strong> ). Indeed, the later form will <strong>never</strong> match the <strong>SuperRare</strong> string !</p>
</li>
<li>
<p dir="auto">This explains the location of the <strong>6</strong> states : <strong><code>(Basic)|(Uncommon)|(Common)|(SuperRare)|(Rare)|(Legendary)</code></strong>. With this syntax, <strong>Claudia</strong>, <strong>no</strong> need to use <strong>look-around</strong> at all. Of course, the <strong>order</strong> becomes <strong><code>0    2    1    4    3    5</code></strong> ;-))</p>
</li>
<li>
<p dir="auto">These <strong>6</strong> states are <strong>surrounded</strong> by the syntax <strong><code>(?:.......)</code></strong>, which is a <strong>non-capturing</strong> group, So, group <strong><code>(Basic)</code></strong> is group <strong><code>1</code></strong>, group <strong><code>(UnCommon)</code></strong> is group <strong><code>2</code></strong> and so on … ( BTW, you write <strong><code>Uncommon</code></strong> and <strong>NOT</strong> <strong><code>UnCommon</code></strong>, whereas you use <strong><code>SuperRare</code></strong> ?!)</p>
</li>
<li>
<p dir="auto">But I came across a <strong>problem</strong> : Let’s imagine the simple regex S/R</p>
</li>
</ul>
<p dir="auto">SEARCH  <strong><code>(?-si)^(.+)(SuperRare|Rare)</code></strong>, with a <strong>case sensitive</strong> search</p>
<p dir="auto">REPLACE <strong><code>&gt;\1&lt; and &gt;\2&lt;</code></strong></p>
<p dir="auto">Then, this regex would <strong>never</strong> find the <strong>first</strong> alternative, with the <strong>SuperRare</strong> word, just because the <strong><code>.+</code></strong> would catch the <strong>greatest</strong> range of characters and just <strong>backtracks</strong> for matching the <strong>Rare</strong> string !! So the text :</p>
<pre><code class="language-diff">ImageNameSuperRare

ImageNameRare
</code></pre>
<p dir="auto">would give :</p>
<pre><code class="language-diff">&gt;ImageNameSuper&lt; and &gt;Rare&lt;

&gt;ImageName&lt; and &gt;Rare&lt;
</code></pre>
<p dir="auto">Now, if we change the <strong>greedy</strong> quantifier <strong><code>+</code></strong> ( meaning <strong><code>{1,}</code></strong>, BTW ) with the <strong>lazy</strong> form <strong><code>+?</code></strong>, this time, it would catch, first, the <strong>tallest</strong> range of characters, before matching one of the <strong>two</strong> branches of the <strong>alternative</strong>. So it does match the <strong>SuperRare</strong> string and, after <strong>replacement</strong>, we get the <strong>expected</strong> text :</p>
<pre><code class="language-diff">&gt;ImageName&lt; and &gt;SuperRare&lt;

&gt;ImageName&lt; and &gt;Rare&lt;
</code></pre>
<p dir="auto">BTW, do you guess why the similar search regex <strong><code>(?-si)^(.+)(Uncommon|Common)</code></strong> does <strong>not</strong> need the <strong>lazy</strong> quantifier ?.. Just because the search is case <strong>sensitive</strong> and there is no <strong>ambiguity</strong> between the string <strong>Un<code>common</code></strong> and the string <strong><code>Common</code></strong> ;-))</p>
<hr />
<p dir="auto"><strong>Notes</strong>, on the <strong>regex</strong> expressions :</p>
<ul>
<li>
<p dir="auto">As usual, the two <strong>modifiers</strong> <strong><code>(?-si)</code></strong>, at beginning of the <strong>search</strong> regex :</p>
<ul>
<li>
<p dir="auto">Forces the regex engine to do a <strong>case-sensitive</strong> search, ( <strong><code>-i</code></strong> ) meaning <strong>NON-Insensitive</strong></p>
</li>
<li>
<p dir="auto">Tell the regex engine to consider the <strong>special</strong> dot character ( <strong><code>.</code></strong> ) as standing for a single <strong>standard</strong> character, and <strong>not</strong> line-break ones !</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Then,  <strong><code>\[\[</code></strong>  matches <strong>two opening square</strong> brackets. Note that these <strong>special</strong> characters must be <strong>escaped</strong> to  be considered as <strong>literal</strong> characters</p>
</li>
<li>
<p dir="auto">Now, the part <strong><code>.+?</code></strong> represents the <strong>tallest range</strong> of any <strong>standard</strong> character, till the states <strong>Basic</strong>, <strong>Common</strong>, …</p>
</li>
<li>
<p dir="auto">The syntax <strong><code>(?:(Basic)|(Uncommon)|(Common)|(SuperRare)|(Rare)|(Legendary))</code></strong> stands for an alternative, in a <strong>non-capturing</strong> group, with <strong>6</strong> branches, stored as <strong>groups</strong> from <strong><code>1</code></strong> to <strong><code>6</code></strong></p>
</li>
<li>
<p dir="auto">Then, the part <strong><code>.+=</code></strong>, matches the <strong>range</strong> of characters, till the <strong>unique</strong> <strong><code>=</code></strong> sign, which does <strong>not</strong> need to be stored</p>
</li>
<li>
<p dir="auto">Finally, the syntax <strong><code>(.+)\]\]</code></strong> represents the <strong>Page Name</strong>, stored as group <strong><code>7</code></strong>, followed by the <strong>two ending square</strong> brackets, which, again, must be <strong>escaped</strong></p>
</li>
<li>
<p dir="auto">In <strong>replacement</strong>, we, first, rewrite the <strong>literal</strong> string <strong><code>{{ItemPic|</code></strong>, followed by the <strong>Page Name</strong> ( <strong><code>$7</code></strong> ) and a <strong><code>|</code></strong>  symbol</p>
</li>
<li>
<p dir="auto">Then, the part <strong><code>(?{1}0)(?{2}2)(?{3}1)(?{4}4)(?{5}3)(?{6}5)</code></strong> are <strong>juxtaposed conditional</strong> replacements, in <strong>any</strong> order, of the <strong>general</strong> form <strong><code>(?{x}y)</code></strong>. It means : IF group <strong><code>x</code></strong> is <strong>matched</strong>, in search, rewrite, in replacement, the expression <strong><code>y</code></strong>. In our case, note that <strong><code>y</code></strong> is, simply, a <strong>digit</strong> number !</p>
</li>
<li>
<p dir="auto">Finally, the part <strong><code>||50px}}</code></strong> is the <strong>literal</strong> string, which have to be rewritten, on any line !</p>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">For <strong>noob</strong> people, about <strong>regular</strong> expressions <strong>concept</strong> and <strong>syntax</strong>, begin with that article, in <strong>N++ Wiki</strong> :</p>
<p dir="auto"><a href="http://docs.notepad-plus-plus.org/index.php/Regular_Expressions" rel="nofollow ugc">http://docs.notepad-plus-plus.org/index.php/Regular_Expressions</a></p>
<p dir="auto">In addition, you’ll find <strong>good documentation</strong>, about the <strong>Boost C++ Regex library, v1.55.0</strong> ( similar to the <strong>PERL Regular Common Expressions, v5.8</strong> ), used by <strong><code>Notepad++</code></strong>, <em>since its <strong><code>6.0</code></strong> version</em>, at the <strong>TWO</strong> addresses below :</p>
<p dir="auto"><a href="http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html" rel="nofollow ugc">http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html</a></p>
<p dir="auto"><a href="http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html" rel="nofollow ugc">http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html</a></p>
<ul>
<li>
<p dir="auto">The <strong>FIRST</strong> link explains the <strong>syntax</strong>, of regular expressions, in the <strong>SEARCH</strong> part</p>
</li>
<li>
<p dir="auto">The <strong>SECOND</strong> link explains the <strong>syntax</strong>, of regular expressions, in the <strong>REPLACEMENT</strong> part</p>
</li>
</ul>
<hr />
<p dir="auto">You may, also, look for <strong>valuable</strong> informations, on the <strong>sites</strong>, below :</p>
<p dir="auto"><a href="http://www.regular-expressions.info" rel="nofollow ugc">http://www.regular-expressions.info</a></p>
<p dir="auto"><a href="http://www.rexegg.com" rel="nofollow ugc">http://www.rexegg.com</a></p>
<p dir="auto"><a href="http://perldoc.perl.org/perlre.html" rel="nofollow ugc">http://perldoc.perl.org/perlre.html</a></p>
<p dir="auto">Be aware that, as any <strong>documentation</strong>, it may contain some <strong>errors</strong> ! Anyway, if you detected one, that’s <strong>good news</strong> : you’re improving ;-))</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28978</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28978</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 27 Dec 2017 04:05:42 GMT</pubDate></item><item><title><![CDATA[Reply to Find and Replace with RegEx help on Tue, 26 Dec 2017 22:21:03 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much. I was able to figure out how the matching expression worked after a time, but I couldn’t figure out the replacement expression. All I was able to figure out is that there were 9 groupings and I could see where each was being used, but I wasn’t able to figure out how the 9 groupings were divided. I also wasn’t exactly sure how the IF ELSE syntax worked. Heck, I didn’t even know it <em>was</em> an IF/ELSE statement.</p>
<p dir="auto">This should help me immensely in the future. I’m an admin and an every day contributor to a wiki with almost 1000 unique articles, hundreds more pages and templates and I’ve been wanting to do some mass updates like this for a long time.</p>
<p dir="auto">Thank you again.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28977</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28977</guid><dc:creator><![CDATA[Ksomeone Msomeone]]></dc:creator><pubDate>Tue, 26 Dec 2017 22:21:03 GMT</pubDate></item><item><title><![CDATA[Reply to Find and Replace with RegEx help on Tue, 26 Dec 2017 19:13:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ksomeone-msomeone" aria-label="Profile: Ksomeone-Msomeone">@<bdi>Ksomeone-Msomeone</bdi></a></p>
<p dir="auto">&lsqb;&lsqb;File:.+((Basic)|((?&lt;!Un)Common)|(Uncommon)|((?&lt;!Super)Rare)|(SuperRare)|(Legendary)).png|(\d+px)|link=(.+)&rsqb;&rsqb;</p>
<p dir="auto">Let#s divide it</p>
<p dir="auto">\[\[File:<br />
we need to escape the square bracket [ by using \[ as the regex engine is using it internally too.</p>
<p dir="auto">.+<br />
whatever data</p>
<p dir="auto">((Basic)|((?&lt;!Un)Common)|(Uncommon)|((?&lt;!Super)Rare)|(SuperRare)|(Legendary))<br />
this is basically an alternation list means we are looking for a match of one of the ones listed<br />
(?&lt;!Un)Common - this means <strong>Common</strong> should not be prefixed by <strong>Un</strong><br />
(?&lt;!Super)Rare) - guess what, yes, <strong>Rare</strong> should not be prefixed by <strong>Super</strong></p>
<p dir="auto">\.png<br />
escape the dot as it has a special meaning in regex too<br />
\|<br />
same is true for the pipe sign<br />
(\d+px)<br />
match any amount of digits, at lest one followed by the literals <strong>px</strong><br />
\|<br />
again escaping pipe<br />
link=(.+)<br />
followed by string <strong>link=</strong> and whatever follows should be matched until<br />
\]\]<br />
closing square brackets, again escaping,</p>
<p dir="auto">This results in 9 match groups which can be reused by using $NUMBER or (?{NUMBER}) syntax<br />
6 matches are reserved by the alternation list and those are the ones which<br />
get assigned to match numbers 2-7, match group 1 is not of interest for us (not even sure why it was needed to be defined),<br />
match group 8 is what is returned by (\d+px) and match group 9 what is<br />
matched after <strong>link=</strong>.</p>
<p dir="auto">Creating the string</p>
<p dir="auto">{{ItemPic|$9|(?{2}0)(?{3}1)(?{4}2)(?{5}3)(?{6}4)(?{7}5)||$8}}</p>
<p dir="auto">$9 = match group 9<br />
(?{2}0) = what matched in match group 2 should be replaced by 0 IF it was found ELSE nothing<br />
(?{3}1) = what matched in match group 3 should be replaced by 1 IF it was found ELSE nothing<br />
…<br />
$8 = match group 8</p>
<p dir="auto">the rest</p>
<p dir="auto">{{ItemPic| | || }}</p>
<p dir="auto">is what you wanted to build.</p>
<p dir="auto">Hope this makes sense to you.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28974</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28974</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 26 Dec 2017 19:13:14 GMT</pubDate></item><item><title><![CDATA[Reply to Find and Replace with RegEx help on Tue, 26 Dec 2017 18:38:11 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">If you are interested and need help understanding what it is doing let us know.</p>
</blockquote>
<p dir="auto">If you want to explain it, I’ll definitely be interested. I’m not sure how much I’ll retain. I’ve tried learning RegEx before, but I give up after a few minutes of staring at the seemingly random mix of symbols.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28973</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28973</guid><dc:creator><![CDATA[Ksomeone Msomeone]]></dc:creator><pubDate>Tue, 26 Dec 2017 18:38:11 GMT</pubDate></item><item><title><![CDATA[Reply to Find and Replace with RegEx help on Tue, 26 Dec 2017 16:16:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ksomeone-msomeone" aria-label="Profile: Ksomeone-Msomeone">@<bdi>Ksomeone-Msomeone</bdi></a></p>
<p dir="auto">given your example</p>
<p dir="auto">Find what:</p>
<pre><code>\[\[File:.+((Basic)|((?&lt;!Un)Common)|(Uncommon)|((?&lt;!Super)Rare)|(SuperRare)|(Legendary))\.png\|(\d+px)\|link=(.+)\]\]
</code></pre>
<p dir="auto">and replace with:</p>
<pre><code>{{ItemPic|$9|(?{2}0)(?{3}1)(?{4}2)(?{5}3)(?{6}4)(?{7}5)||$8}}
</code></pre>
<p dir="auto">turns this</p>
<pre><code>&lsqb;&lsqb;File:ImageNameBasic.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameCommon.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameUncommon.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameRare.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameSuperRare.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageNameLegendary.png|50px|link=Page Name&rsqb;&rsqb;
&lsqb;&lsqb;File:ImageName|50px|link=&rsqb;&rsqb;
</code></pre>
<p dir="auto">into that</p>
<pre><code>{{ItemPic|Page Name|0||50px}}
{{ItemPic|Page Name|1||50px}}
{{ItemPic|Page Name|2||50px}}
{{ItemPic|Page Name|3||50px}}
{{ItemPic|Page Name|4||50px}}
{{ItemPic|Page Name|5||50px}}
&lsqb;&lsqb;File:ImageName|50px|link=&rsqb;&rsqb;
</code></pre>
<p dir="auto">If you are interested and need help understanding what it is doing let us know.</p>
<p dir="auto">Cheers<br />
Claudia</p>
]]></description><link>https://community.notepad-plus-plus.org/post/28970</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/28970</guid><dc:creator><![CDATA[Claudia Frank]]></dc:creator><pubDate>Tue, 26 Dec 2017 16:16:25 GMT</pubDate></item></channel></rss>