<?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[Using std::regex causes plugin loading to fail — is there an alternative?]]></title><description><![CDATA[<p dir="auto">While working on a plugin using Visual Studio 2022, I noticed that when I added some std::regex code, the plugin build was successful but Notepad++ could not load it. Removing the std::regex code made it work again.</p>
<p dir="auto">I’m guessing this has something to do with the statement in build . md of Notepad++ that “Notepad++ is always built <strong>with</strong> Boost regex PCRE support instead of default c++11 regex ECMAScript used by plain Scintilla.” But the implications of that are beyond my understanding of C++ linkage and libraries.</p>
<p dir="auto">Is there a way to use regular expressions in a C++ plugin for Notepad++? For my purposes, it probably doesn’t have to be std::regex, though I’ve never used the Boost libraries and have no idea how they work.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/23931/using-std-regex-causes-plugin-loading-to-fail-is-there-an-alternative</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 00:01:36 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/23931.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 Dec 2022 05:03:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using std::regex causes plugin loading to fail — is there an alternative? on Sat, 04 Feb 2023 19:47:49 GMT]]></title><description><![CDATA[<p dir="auto">The problem was not at all what I thought. It turned out to be ordinary user error. There was a fault in the syntax of my regular expression. Having never used C++ regular expressions before, I didn’t know that even when the expression is coded as a character literal, Visual Studio compiles code containing invalid regular expressions without complaint and then throws a <em>run-time</em> error. Because it was in a plug-in dll and it was a static constant (hence, processed on loading), the dll failed to load at all.</p>
<p dir="auto">There is no problem loading a plugin that uses std::regex, so long as the expression doesn’t cause an exception.</p>
<p dir="auto">Thanks to those who replied.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83880</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83880</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Sat, 04 Feb 2023 19:47:49 GMT</pubDate></item><item><title><![CDATA[Reply to Using std::regex causes plugin loading to fail — is there an alternative? on Tue, 24 Jan 2023 19:12:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/derek-brown" aria-label="Profile: Derek-Brown">@<bdi>Derek-Brown</bdi></a> said in <a href="/post/83588">Using std::regex causes plugin loading to fail — is there an alternative?</a>:</p>
<blockquote>
<p dir="auto">easy to set up vcpkg for use with Visual Studio, if you haven’t already. If you have trouble, I can provide some help</p>
</blockquote>
<p dir="auto">I’d think there might be better, more on-topic, forums for that, but let’s see how it goes.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83594</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83594</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 24 Jan 2023 19:12:33 GMT</pubDate></item><item><title><![CDATA[Reply to Using std::regex causes plugin loading to fail — is there an alternative? on Tue, 24 Jan 2023 18:49:36 GMT]]></title><description><![CDATA[<p dir="auto">You could try using <a href="https://github.com/google/re2" rel="nofollow ugc">re2</a>, which is a regex engine by Google, much faster than std::regex, and is available in vcpkg. I have used it in a plugin myself.</p>
<p dir="auto">All of Boost is also available in vcpkg, so if you’re unsure how to install Boost that is the best way to go.</p>
<p dir="auto">It is pretty easy to set up vcpkg for use with Visual Studio, if you haven’t already. If you have trouble, I can provide some help, but give it a try first.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/83588</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/83588</guid><dc:creator><![CDATA[Derek Brown]]></dc:creator><pubDate>Tue, 24 Jan 2023 18:49:36 GMT</pubDate></item><item><title><![CDATA[Reply to Using std::regex causes plugin loading to fail — is there an alternative? on Fri, 23 Dec 2022 08:02:37 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">I’m guessing this has something to do with the statement in build . md of Notepad++ that “Notepad++ is always built <strong>with</strong> Boost regex PCRE support instead of default c++11 regex ECMAScript used by plain Scintilla.”</p>
</blockquote>
<p dir="auto">Boost is just the regex engine for the editor’s find &amp; replace capabilities. There’s no requirement to use any Boost APIs in a plugin. (You would have to copy the Boost header files into your own project to make that possible).</p>
<blockquote>
<p dir="auto">Removing the std::regex code made it work again.</p>
</blockquote>
<p dir="auto">The reason why is basically what you quoted from <code>BUILD.md</code>. Notepad++ “turns off” C++11’s builtin regex support in favour of Boost, as explained <a href="https://www.scintilla.org/ScintillaDoc.html#Searching:~:text=The%20C%2B%2B11%20%3Cregex%3E%20support%20may%20be%20disabled%20by%20compiling%20Scintilla%20with%20NO_CXX11_REGEX%20defined" rel="nofollow ugc">here</a>:</p>
<blockquote>
<p dir="auto">The C++11 &lt;regex&gt; support may be disabled by compiling Scintilla with NO_CXX11_REGEX defined.</p>
</blockquote>
<p dir="auto"><a href="https://www.scintilla.org/ScintillaDoc.html#AlternativeRegEx:~:text=Build%20Scintilla%20without%20C%2B%2B11%20std%3A%3Aregex." rel="nofollow ugc">and here</a>:</p>
<blockquote>
<p dir="auto">A simple interface provides support for switching the Regular Expressions engine at compile time.<br />
. . .</p>
<h4>Preprocessors affect building</h4>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="text-align:left">Preprocessor</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">NO_CXX11_REGEX</td>
<td style="text-align:left">Build Scintilla without C++11 std::regex.</td>
</tr>
</tbody>
</table>
</blockquote>
<blockquote>
<p dir="auto">Is there a way to use regular expressions in a C++ plugin for Notepad++?</p>
</blockquote>
<p dir="auto"><a href="https://www.scintilla.org/ScintillaDoc.html#Searching" rel="nofollow ugc">Scintilla’s APIs</a> may be enough to get the job done, even if they are “<a href="https://www.scintilla.org/ScintillaDoc.html#Searching:~:text=The%20base%20regular%20expression%20support%20is%20limited%20and%20should%20only%20be%20used%20for%20simple%20cases%20and%20initial%20development" rel="nofollow ugc">limited and should only be used for simple cases and initial development</a>”.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/82705</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/82705</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Fri, 23 Dec 2022 08:02:37 GMT</pubDate></item></channel></rss>