<?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 OR in replace. How to adress given group?]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">When using find, you can do something like (X|Y) and notepad will find both of these. How can i adress these alternative groups in replace?</p>
<p dir="auto">A simplified example: Lets say we want to swap true and false in these lines:</p>
<p dir="auto">A candy is true .<br />
A candy is false .<br />
A candy is true .<br />
A candy is false .<br />
A candy is true .</p>
<p dir="auto">Find: (true)|(false)</p>
<p dir="auto">I tried using something like \2\1 or \1\2 in replace, but then it does nothing?<br />
How can i set replace option for each alternative?<br />
Again, this is only simplified example so 3-step replace is not satisfying :)</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/18161/using-or-in-replace-how-to-adress-given-group</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 12:57:48 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/18161.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Aug 2019 06:05:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using OR in replace. How to adress given group? on Fri, 30 Aug 2019 12:02:09 GMT]]></title><description><![CDATA[<p dir="auto">A couple of more good references to this technique:</p>
<ul>
<li><a href="https://notepad-plus-plus.org/community/topic/12887/switching-letters-with-one-regex" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/12887/switching-letters-with-one-regex</a></li>
<li><a href="https://notepad-plus-plus.org/community/topic/14157/change-a-word-in-regex" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/14157/change-a-word-in-regex</a></li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/46694</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/46694</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 30 Aug 2019 12:02:09 GMT</pubDate></item><item><title><![CDATA[Reply to Using OR in replace. How to adress given group? on Fri, 30 Aug 2019 08:25:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/adrianhhh" aria-label="Profile: AdrianHHH">@<bdi>AdrianHHH</bdi></a> said:</p>
<blockquote>
<p dir="auto">Try a regular expression replace of<br />
(A candy is true)|(A candy is false)<br />
with<br />
(?1A candy is false)(?2A candy is true)</p>
<p dir="auto">See<br />
<a href="https://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html" rel="nofollow ugc">https://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html</a></p>
</blockquote>
<p dir="auto">Thanks! This works :) . I went to this page before but i must’ve misunderstood</p>
<blockquote>
<p dir="auto">"For example, the format string “(?1foo:bar)” will replace each match found with “foo” if the sub-expression $1 was matched, and with “bar” otherwise. "</p>
</blockquote>
<p dir="auto">I tried to use it with “:” between alternatives, but that didn’t quite work. Your solution with (?N  smg ) works just right.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/46692</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/46692</guid><dc:creator><![CDATA[Adam Prochowski]]></dc:creator><pubDate>Fri, 30 Aug 2019 08:25:50 GMT</pubDate></item><item><title><![CDATA[Reply to Using OR in replace. How to adress given group? on Fri, 30 Aug 2019 08:11:52 GMT]]></title><description><![CDATA[<p dir="auto">Try a regular expression replace of<br />
(A candy is true)|(A candy is false)<br />
with<br />
(?1A candy is false)(?2A candy is true)</p>
<p dir="auto">See<br />
<a href="https://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html" rel="nofollow ugc">https://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/46691</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/46691</guid><dc:creator><![CDATA[AdrianHHH]]></dc:creator><pubDate>Fri, 30 Aug 2019 08:11:52 GMT</pubDate></item><item><title><![CDATA[Reply to Using OR in replace. How to adress given group? on Fri, 30 Aug 2019 07:26:32 GMT]]></title><description><![CDATA[<p dir="auto">@gurikbal-singh said:</p>
<blockquote>
<p dir="auto">find what : A candy is .*$</p>
<p dir="auto">Search mode: Regular expression</p>
</blockquote>
<p dir="auto">This changes whole subject to a small regex workaround that doesnt work as indented. I Want to have both alternatives and i want to replace based on which alternative is found. So if you find “true” replace with false, if you find “false” replace with true. this is again simplified. Once i get this to work, the alternatives will be contucted of regexes and the replace will be also based on groups i find using regex. I only pinpointed the part i have trouble with - How to adress alternative in find - so that people don’t go into understanding unnecessary commands when question is simple.</p>
<p dir="auto">Hope this clarifies the problem.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/46690</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/46690</guid><dc:creator><![CDATA[Adam Prochowski]]></dc:creator><pubDate>Fri, 30 Aug 2019 07:26:32 GMT</pubDate></item><item><title><![CDATA[Reply to Using OR in replace. How to adress given group? on Fri, 30 Aug 2019 07:01:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/adam-prochowski" aria-label="Profile: Adam-Prochowski">@<bdi>Adam-Prochowski</bdi></a> said:</p>
<blockquote>
<p dir="auto">When using find, you can do something like (X|Y) and notepad will find both of these</p>
</blockquote>
<p dir="auto">find what : A candy is .*$</p>
<p dir="auto">Search mode: Regular expression</p>
]]></description><link>https://community.notepad-plus-plus.org/post/46689</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/46689</guid><dc:creator><![CDATA[rinku singh]]></dc:creator><pubDate>Fri, 30 Aug 2019 07:01:25 GMT</pubDate></item></channel></rss>