<?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[Need help, please - regular expressions]]></title><description><![CDATA[<p dir="auto">Can not cope with it:<br />
example source:</p>
<p dir="auto">&lt;img lorem-ipsum-dolor=“/lorem/ipsum/dolor-2015-and/123456789012345/lorem_ipsum/1a2b3c4dd9651/a23w34m87.jpg” class=“lorem123” src=“11LOREM%202%20%20IpSuM%20Dolor%20sit%20%20amet%20consecteur%20-%20AdiPISCIng%20123456%20elit%20Curabitur%20QWERTY%20202020%20yes%20urna%20Interdeum%20%20Off%20Cras_files/a01b02c68.png” alt=“a01b02c68.bmp” height=“101” width=“102”&gt;</p>
<p dir="auto">regex search:</p>
<p dir="auto">(?:&lt;img lorem-ipsum-dolor)(?:.<em>?)( class=|)(".</em>?“)( src=)(?:.<em>?)(?:_files/)(.</em>?.[jpg|png|tif|gif]”)</p>
<p dir="auto">replace:</p>
<p dir="auto">&lt;img\1\2\3"\4</p>
<p dir="auto">and I get this:</p>
<p dir="auto">&lt;img"/lorem/ipsum/dolor-2015-and/123456789012345/lorem_ipsum/1a2b3c4dd9651/a23w34m87.jpg" class=“lorem123” src=“a01b02c68.png” alt=“a01b02c68.bmp” height=“101” width=“102”&gt;</p>
<p dir="auto">This should not be:</p>
<p dir="auto">“/lorem/ipsum/dolor-2015-and/123456789012345/lorem_ipsum/1a2b3c4dd9651/a23w34m87.jpg”</p>
<p dir="auto">It should look like:</p>
<p dir="auto">&lt;img class=“lorem123” src=“a01b02c68.png” alt=“a01b02c68.bmp” height=“101” width=“102”&gt;</p>
<p dir="auto">What am I doing wrong?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/10935/need-help-please-regular-expressions</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 11:43:53 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/10935.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Dec 2015 07:27:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Need help, please - regular expressions on Fri, 11 Dec 2015 20:29:22 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for your commitment<br />
Best regards,<br />
Jan</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12571</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12571</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Fri, 11 Dec 2015 20:29:22 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Fri, 11 Dec 2015 20:13:49 GMT]]></title><description><![CDATA[<p dir="auto">Hi <strong>Jan</strong>,</p>
<p dir="auto">OK. I, now, understood <strong>two</strong> main points, about your problem :</p>
<ul>
<li>
<p dir="auto">Firstly, the values of the different <strong>tags</strong> are surrounded by the <strong>usual</strong> quotation mark ( <strong><code>"</code></strong> ), of <strong>Unicode</strong> code-point <strong><code>\x{0022}</code></strong>. Of course, my <strong>previous</strong> regex,  based on the two delimiters <strong><code>\x{201c}</code></strong> and <strong><code>\x{201d}</code></strong>, COULDN’T work at all !</p>
</li>
<li>
<p dir="auto">Secondly, the tag <strong><code>class="........"</code></strong> may, sometimes, be <strong>absent</strong>, in a line. Again, my <strong>previous</strong> regex supposed that this <strong>tag</strong> was <strong>always</strong> present:-((</p>
</li>
</ul>
<p dir="auto">So, aware of the <strong>two</strong> facts, above, my <strong>new proposed</strong> regex is :</p>
<p dir="auto">SEARCH <strong><code>(?i-s)&lt;img lorem-ipsum-dolor.*?((?:class=".*?" )?src=").*?_files/(.*?(jpg|png|tiff|gif))</code></strong></p>
<p dir="auto">REPLACE <strong><code>&lt;img \L\1\2</code></strong></p>
<p dir="auto">After running <strong>your</strong> S/R and <strong>mine</strong>, they, <strong>both</strong>, give the <strong>same</strong> results :-)) Nice !</p>
<hr />
<p dir="auto"><strong>NOTES</strong> : Compared to my <strong>previous</strong> try :</p>
<ul>
<li>
<p dir="auto">I changed the special delimiters <strong><code>“.....”</code></strong>, by the usual ones <strong><code>"....."</code></strong>, in the <strong>search</strong> regex</p>
</li>
<li>
<p dir="auto">I added a new <strong>non-capturing</strong> group <strong><code>(?:class=".*?" )?</code></strong>, that can <strong>exists</strong> or <strong>NOT</strong>, due to the final question mark <strong><code>?</code></strong></p>
</li>
<li>
<p dir="auto">There a <strong>space</strong>, ending the <strong>non-capturing</strong> group, before the <strong>ending round</strong> bracket</p>
</li>
<li>
<p dir="auto">The <strong>replacement</strong> regex has <strong>NOT</strong> changed</p>
</li>
</ul>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12568</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12568</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 11 Dec 2015 20:13:49 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Fri, 11 Dec 2015 16:48:28 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much for analysis. I know, abnormal brackets, do not have the right to work. But in this specific example, work.<br />
Example:<br />
<code>&lt;img lorem-ipsum-dolor="/lorem/ipsum/dolor-2015-and/123456789012345/lorem_ipsum/1a2b3c4dd9651/a23w34m87.jpg" class="lorem123" src="11LOREM%202%20%20IpSuM%20Dolor%20sit%20%20amet%20consecteur%20-%20AdiPISCIng%20123456%20elit%20Curabitur%20QWERTY%20202020%20yes%20urna%20Interdeum%20%20Off%20Cras_files/a01b02c68.png" alt="a01b02c68.bmp" height="101" width="102"&gt;</code></p>
<p dir="auto"><code>&lt;img lorem-ipsum-dolor="/lorem/ipsum/dolor-1999-and/123456789012345/lorem_ipsum/1a2b3c4dd9651/c011XX001.tif" src="11LOREM%202%20%20IpSuM%20Dolor%20sit%20%20amet%20consecteur%20-%20AdiPISCIng%20123456%20elit%20Curabitur%20QWERTY%20202020%20yes%20urna%20Interdeum%20%20Off%20Cras_files/c01vv0x01.jpg" alt="c01vv0x01.jpeg" height="567" width="789"&gt;</code></p>
<p dir="auto">Regex:<br />
<code>(?:&lt;img lorem-ipsum-dolor)(?:.*?)(?:( class=)(".*?")( src=)|( src=))(?:.*?)(?:_files\/)(.*?[jpg|png|tif|gif]")</code><br />
replace:<br />
<code>&lt;img\1\2\3\4"\5</code></p>
<p dir="auto">After changing to the correct brackets, also works:<br />
<code>(?:&lt;img lorem-ipsum-dolor)(?:.*?)(?:( class=)(".*?")( src=)|( src=))(?:.*?)(?:_files\/)(.*?(jpg|png|tif|gif)")</code><br />
but then there are 6 groups, the sixth just do not need to call.</p>
<p dir="auto">With all due respect, your as much as possible correct regex is not working.</p>
<p dir="auto">Very sorry for my English, still I am learning.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12561</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12561</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Fri, 11 Dec 2015 16:48:28 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Thu, 10 Dec 2015 23:06:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello <strong>Jan</strong> and <strong>Dail</strong>,</p>
<p dir="auto"><strong>Jan</strong>, I didn’t try to consider your regex S/R, <strong>first</strong>, trying to <strong>fully</strong> understand it. I just notice <strong>two</strong> points :</p>
<ul>
<li>After copying your <strong>example source</strong>, in my Notepad++, the <strong>delimiters</strong> of the different tags ( <strong>class</strong>, <strong>src</strong>, <strong>alt</strong>, <strong>height</strong> and <strong>width</strong> ) are the couple <strong><code>“.....”</code></strong>, that is to say the <strong>Left DOUBLE quotation MARK</strong> ( of <strong>Unicode</strong> code-point <strong><code>\x{201c}</code></strong> ) and the <strong>Right DOUBLE quotation MARK</strong> ( of <strong>Unicode</strong> code-point <strong><code>\x201d</code></strong> ). These characters are <strong>different</strong> from the usual <strong>QUOTATION MARK</strong> <strong><code>"</code></strong> ( <strong><code>\x22</code></strong> )</li>
</ul>
<p dir="auto">Therefore, the regex, proposed below, is <strong>based</strong> on these <strong>two</strong> characters <strong><code>\x{201c}</code></strong> and <strong><code>\x{201d}</code></strong></p>
<ul>
<li>Seemingly, your <strong>pictures</strong> files can have the <strong>.jpg</strong>, <strong>.png</strong>, <strong>.tiff</strong> or <strong>.gif</strong> extension. Well, but the regex you use to match these <strong>extensions</strong> ( <strong><code>[jpg|png|tif|gif]</code></strong> ) is <strong>totally WRONG</strong>, because the <strong><code>|</code></strong> symbol  is taken literally, between <strong>square</strong> brackets !. Indeed, this syntax is a single <strong>range</strong> of characters, which matches an <strong>unique</strong> character, which can be the <strong>pipe</strong> symbol (<strong><code>|</code></strong> ), OR <strong>one</strong> of the letters <strong>j</strong>, <strong>p</strong>, <strong>g</strong>, <strong>n</strong>, <strong>t</strong>, <strong>i</strong>, <strong>f</strong>, whatever their <strong>case</strong>. In other words, this <strong>subset</strong>, of your entire regex, could be simply rewritten <strong><code>[fgijnpt|]</code></strong></li>
</ul>
<p dir="auto">So, the <strong>correct</strong> regex is simply <strong><code>(jpg|png|tiff|gif)</code></strong> : <strong>one</strong> extension, among the <strong>four</strong> possible ones !</p>
<hr />
<p dir="auto">Then, I propose the following <strong>regex</strong> S/R, below :</p>
<p dir="auto">SEARCH <strong><code>(?i-s).*?(class=“.*?” src=“).*?_files/(.*?(jpg|png|tiff|gif))</code></strong> ( with a <strong>space</strong>, before the tag <strong>src</strong> )</p>
<p dir="auto">REPLACE <strong><code>&lt;img \L\1\2</code></strong></p>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">The two modifiers <strong><code>(?i-s)</code></strong> forces matches, in an <strong>insensitive</strong> way and that <strong>dot</strong> matches <strong>standard</strong> characters <strong>only</strong>. In replacement, however, the <strong>two</strong> groups <strong><code>\1</code></strong> and <strong><code>\2</code></strong> are rewritten, in <strong>lower</strong> case, due to the <strong><code>\L</code></strong> syntax</p>
</li>
<li>
<p dir="auto">The four forms <strong><code>.*?</code></strong> represents the <strong>shortest</strong> list of characters, before <strong>each</strong> string, located after <strong>.*?</strong></p>
</li>
<li>
<p dir="auto"><strong>All</strong> text, before the <strong>first</strong> string <strong>class</strong>, of a line, NOT located between <strong>round</strong> brackets, is therefore <strong>deleted</strong>, after replacement</p>
</li>
<li>
<p dir="auto">The group <strong><code>\1</code></strong> is the string <strong>class=“…” src=“</strong> and the group <strong><code>\2</code></strong> is the <strong>name</strong> of the picture, with its <strong>extension</strong>. They, <strong>both</strong>, are rewritten, in <strong>lower</strong> case, after an initial <strong>&lt;img</strong> string.</p>
</li>
</ul>
<p dir="auto">If your really need that the line <strong>begins</strong> with the string <strong>&lt;img lorem-ipsum-dolor</strong>, just change the <strong>search</strong> regex into :</p>
<p dir="auto">SEARCH <strong><code>(?i-s)&lt;img lorem-ipsum-dolor.*?(class=“.*?” src=“).*?_files/(.*?(jpg|png|tiff|gif))</code></strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12543</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12543</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 10 Dec 2015 23:06:06 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Thu, 10 Dec 2015 09:55:44 GMT]]></title><description><![CDATA[<p dir="auto">Finally<br />
&lt;code&gt;(?:&lt;img lorem-ipsum-dolor)(?:.*?)(?:( class=)(“.*?”)( src=)|( src=))(?:.*?)(?:_files/)(.*?[jpg|png|tif|gif]")&lt;/code&gt;</p>
<p dir="auto">ps. I don’t know why me didn’t show in red :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12528</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12528</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Thu, 10 Dec 2015 09:55:44 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 18:32:19 GMT]]></title><description><![CDATA[<p dir="auto">I’m sorry I was blind doesn’t work</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12515</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12515</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Wed, 09 Dec 2015 18:32:19 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 17:59:24 GMT]]></title><description><![CDATA[<p dir="auto">(?:&lt;img lorem-ipsum-dolor)(?:.*?)(?&gt;( class=|)(“.*?”))?(“.*?”)( src=)(?:.*?)(?:_files/)(.*?[jpg|png|tif|gif]")</p>
<p dir="auto">atomic group, works<br />
Thx for right direction!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12513</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12513</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Wed, 09 Dec 2015 17:59:24 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 16:04:18 GMT]]></title><description><![CDATA[<p dir="auto">In the picture looks great. In real it’s always left on the front :(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12508</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12508</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Wed, 09 Dec 2015 16:04:18 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 15:48:08 GMT]]></title><description><![CDATA[<p dir="auto">You are right. <code>( class=|)</code> can skip it. If you look at the image I linked, if it skips group 1, it <em>must still</em> “consume” something for group 2. So you would want a regular expression that only captures group 2 if 1 exists.</p>
<p dir="auto">So this section in your expression:</p>
<p dir="auto"><code>( class=|)(".*?")</code></p>
<p dir="auto">Should be replaced with something like:</p>
<p dir="auto"><code>(?:( class=)(".*?"))?</code></p>
<p dir="auto"><strong>Note</strong> this isn’t perfect but should point you in the right direction.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12507</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12507</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Wed, 09 Dec 2015 15:48:08 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 15:25:26 GMT]]></title><description><![CDATA[<p dir="auto">Shortening again takes revenge, i want shortly, came badly.<br />
Expression is also fit to:</p>
<p dir="auto">&lt;img lorem-ipsum-dolor=“/lorem/ipsum/dolor-1999-and/123456789012345/lorem_ipsum/1a2b3c4dd9651/c011XX001.tif” src=“11LOREM%202%20%20IpSuM%20Dolor%20sit%20%20amet%20consecteur%20-%20AdiPISCIng%20123456%20elit%20Curabitur%20QWERTY%20202020%20yes%20urna%20Interdeum%20%20Off%20Cras_files/c01vv0x01.jpg” alt=“c01vv0x01.jpeg” height=“567” width=“789”&gt;</p>
<p dir="auto">IMHO  ( class=|)  It meant with it, or without it. I emphasize IMHO.<br />
Without it, not checked second expression. Because  |  means OR, right?<br />
And so it looks, sorry…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12506</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12506</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Wed, 09 Dec 2015 15:25:26 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 14:33:07 GMT]]></title><description><![CDATA[<p dir="auto">Also, take a look at your original expression <a href="http://regexper.com/#(%3F%3A%3Cimg%20lorem-ipsum-dolor)(%3F%3A.*%3F)(%20class%3D%7C)(%22.*%3F%22)(%20src%3D)(%3F%3A.*%3F)(%3F%3A_files%5C%2F)(.*%3F.%5Bjpg%7Cpng%7Ctif%7Cgif%5D%22)" rel="nofollow ugc">here</a>. You can see the regular expression is allowing it to <em>skip</em> <code>class=</code>.</p>
<p dir="auto">Note: that website might not use the exact same regular expression engine but should be close enough to reference.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12505</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12505</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Wed, 09 Dec 2015 14:33:07 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 14:27:56 GMT]]></title><description><![CDATA[<p dir="auto">Very close. You had one minor issue. This:</p>
<p dir="auto"><code>( class=|)</code></p>
<p dir="auto">Should be</p>
<p dir="auto"><code>( class=)</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/12504</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12504</guid><dc:creator><![CDATA[dail]]></dc:creator><pubDate>Wed, 09 Dec 2015 14:27:56 GMT</pubDate></item><item><title><![CDATA[Reply to Need help, please - regular expressions on Wed, 09 Dec 2015 10:04:08 GMT]]></title><description><![CDATA[<p dir="auto">at the top cuts stars, sorry</p>
<p dir="auto">regex search:<br />
(?:&lt;img lorem-ipsum-dolor)(?:.*?)( class=|)(“.*?”)( src=)(?:.*?)(?:_files/)(.*?.[jpg|png|tif|gif]")</p>
]]></description><link>https://community.notepad-plus-plus.org/post/12499</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/12499</guid><dc:creator><![CDATA[Jan Kowalsky]]></dc:creator><pubDate>Wed, 09 Dec 2015 10:04:08 GMT</pubDate></item></channel></rss>