<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent posts to Problem with lookahead</title><link>https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/</link><description>Recent posts to Problem with lookahead</description><atom:link href="https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/feed.rss" rel="self"/><language>en</language><lastBuildDate>Mon, 03 Feb 2020 19:00:44 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/feed.rss" rel="self" type="application/rss+xml"/><item><title>Problem with lookahead</title><link>https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/?limit=25#858d/e7fe/bbb0/30e7/f5f3</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Ah! I see what you meant now. I started learning Python and regex thanks to this add in. I like how elegent and streamlined that addition was, and it worked perfectly. Thanks for the input!&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stacey Barr</dc:creator><pubDate>Mon, 03 Feb 2020 19:00:44 -0000</pubDate><guid>https://sourceforge.net37d79a6320868d6bad8cb1cac5b4066bad2e62cd</guid></item><item><title>Problem with lookahead</title><link>https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/?limit=250#858d/e7fe/bbb0/30e7</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Right at the front, just like I said.  I tried it with your data set and got the results you expected.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;editor.rereplace(r"(?s)(^F1 VA \d+ )(?=.*\1)", r"! \1")&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;without the &lt;code&gt;(?s)&lt;/code&gt; the &lt;code&gt;.&lt;/code&gt; won't match end-of-line characters.  With it, it will.  That way you can still use the &lt;code&gt;.&lt;/code&gt; and don't have to resort to the &lt;code&gt;[\s\S]&lt;/code&gt; trick (although that works fine, too).&lt;/p&gt;
&lt;p&gt;Aside:  When you use the &lt;code&gt;.*&lt;/code&gt; pattern, you should always first consider using it as &lt;code&gt;.*?&lt;/code&gt; so that it matches minimally.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sasumner</dc:creator><pubDate>Sat, 01 Feb 2020 15:13:46 -0000</pubDate><guid>https://sourceforge.net84bc4a9c3aea789bfb5d8e288eac0a5f8c423275</guid></item><item><title>Problem with lookahead</title><link>https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/?limit=25#858d/e7fe/bbb0</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;I tried using your suggestion in a number of different ways, but didn't have any luck. Where in the line were you expecting it to go?&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stacey Barr</dc:creator><pubDate>Fri, 31 Jan 2020 18:37:20 -0000</pubDate><guid>https://sourceforge.nete580c9926b17e3030bfe0ae95a54e96046cf0595</guid></item><item><title>Problem with lookahead</title><link>https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/?limit=250#858d/e7fe</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;"single line flag"?&lt;br/&gt;
"Pythonscript wants..." -&amp;gt; it's about what YOU want :-)&lt;/p&gt;
&lt;p&gt;I think I see what you are saying though.&lt;br/&gt;
You could have left your original regex alone and just added &lt;code&gt;(?-s)&lt;/code&gt;to the front of it.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sasumner</dc:creator><pubDate>Thu, 30 Jan 2020 12:42:29 -0000</pubDate><guid>https://sourceforge.net030beb5050730aa04de9e46625f0b7db74eb5a05</guid></item><item><title>Problem with lookahead</title><link>https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/?limit=25#858d</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Found the solution. For future reference, Python Scrip wants to see the single line flag used in the search.&lt;br/&gt;
&lt;code&gt;editor.rereplace(r"(^F1 VA \d+ )(?=[\s\S]*\1)",r"! \1")&lt;/code&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stacey Barr</dc:creator><pubDate>Wed, 29 Jan 2020 20:30:22 -0000</pubDate><guid>https://sourceforge.netecd35288a238309a6c46cb408929f2d893482cb7</guid></item><item><title>Problem with lookahead</title><link>https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/957497d322/?limit=25#56d7</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Does Python Script support lookahead? I’m trying to get this regex to work, but it keeps failing.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;editor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rereplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="ss"&gt;"(^F1 VA \d+ )(?=.*\1)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="ss"&gt;"! \1"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;For more backstory (and an example dataset), here’s a link to a reddit post.&lt;br/&gt;
&lt;a href="https://www.reddit.com/r/regex/comments/eutmta/finding_duplicates_using_a_lookahead/" rel="nofollow"&gt;https://www.reddit.com/r/regex/comments/eutmta/finding_duplicates_using_a_lookahead/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance for any input! This is driving me crazy.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stacey Barr</dc:creator><pubDate>Wed, 29 Jan 2020 17:22:27 -0000</pubDate><guid>https://sourceforge.net8dc43d04cd3cfc4513565dcf71be16f545c52044</guid></item></channel></rss>