<?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[Regex: search the nearest words at a maximum distance of 6 words]]></title><description><![CDATA[<p dir="auto">hello, again. I want to FIND THE NEAREST WORDS at a maximum distance of 6 words. For exemple:</p>
<p dir="auto">bla bla <code>WORD_A</code>  blah bla blah bla bla blah <code>WORD_B</code> blah blah…</p>
<p dir="auto">So, between word can be 6 other words, or seven, etc, depends on what I want.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/12368/regex-search-the-nearest-words-at-a-maximum-distance-of-6-words</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 18:16:56 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/12368.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 Sep 2016 19:17:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Tue, 11 Dec 2018 09:59:38 GMT]]></title><description><![CDATA[<p dir="auto">But i want to asked if i need to check they are not near in range { 6,12 }.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37372</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37372</guid><dc:creator><![CDATA[Bipulkumarsingh]]></dc:creator><pubDate>Tue, 11 Dec 2018 09:59:38 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Sat, 24 Sep 2016 20:45:25 GMT]]></title><description><![CDATA[<p dir="auto">nice answer, thanks for replying me every time, Guy.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/18072</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18072</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Sat, 24 Sep 2016 20:45:25 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Sat, 24 Sep 2016 19:49:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi <strong>Vasile</strong>,</p>
<p dir="auto">Just consider the simple string <strong>“Vasile Caraus”</strong>  You won’t forget it, won’t you !!! Then :</p>
<ul>
<li>
<p dir="auto">The regex <strong><code>s.+a</code></strong>, with a <strong>greeedy</strong> quantifier <strong><code>+</code></strong>, would match the string <strong>sile Cara</strong></p>
</li>
<li>
<p dir="auto">The regex <strong><code>s.+?a</code></strong>, with the <strong>lazy</strong> quantifier <strong><code>+?</code></strong>, would match the string <strong>sile Ca</strong></p>
</li>
</ul>
<hr />
<p dir="auto">More seriously, let’s imagine this <strong>HTML</strong> code, split on <strong>four</strong> lines, below :</p>
<pre><code>&lt;td width="80"&gt;
  &lt;a href="javascript:doit%20('Act_V_Next',1,1)"&gt;&lt;font face="arial, verdana" size="1" color="#006699"&gt;
  &lt;b&gt;Suivant&amp;gt;&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;/a&gt;
&lt;/td&gt;
</code></pre>
<ul>
<li>
<p dir="auto">Type in, <strong>firstly</strong>, the regex <strong><code>&lt;.+&gt;</code></strong>, and click, <strong>several</strong> times, on the <strong>Find Next</strong> button…</p>
</li>
<li>
<p dir="auto">Type in, <strong>secondly</strong>, the regex <strong><code>&lt;.+?&gt;</code></strong>, and click, <strong>several</strong> times, on the <strong>Find Next</strong> button…</p>
</li>
</ul>
<p dir="auto">In the <strong>second</strong> case, you always get <strong>individual correct</strong> tags !</p>
<p dir="auto">In order to get the <strong>same</strong> behaviour, <em>without</em> a <strong>lazy</strong> quantifier, you could use the regex <strong><code>&lt;[^&gt;]+&gt;</code></strong>. And, if you refer to the <strong>link</strong>, below :</p>
<p dir="auto"><a href="http://www.regular-expressions.info/repeat.html" rel="nofollow ugc">http://www.regular-expressions.info/repeat.html</a></p>
<p dir="auto">This <strong>third</strong> solution is even <strong>better</strong>, as it prevents the regex engine from any <strong>backtracking</strong> !! Please, read, particularly, the <strong>two</strong> sections <strong>“Laziness Instead of Greediness”</strong> and <strong>“An Alternative to Laziness”</strong></p>
<p dir="auto">Look, also, at the chapter, section <strong>“How Possessive Quantifiers Work”</strong> , at :</p>
<p dir="auto"><a href="http://www.regular-expressions.info/possessive.html" rel="nofollow ugc">http://www.regular-expressions.info/possessive.html</a></p>
<hr />
<p dir="auto">So, in short :</p>
<ul>
<li>
<p dir="auto">Add the <strong><code>?</code></strong> meta-character, AFTER a <strong>greedy</strong> quantifier ( <strong>Default</strong> case ) to make <em>this</em> quantifier <strong><code>lazy</code></strong></p>
</li>
<li>
<p dir="auto">Add the <strong><code>+</code></strong> meta-character, AFTER a <strong>greedy</strong> quantifier ( <strong>Default</strong> case ) to make <em>this</em> quantifier <strong><code>possessive</code></strong></p>
</li>
</ul>
<p dir="auto">And :</p>
<ul>
<li>
<p dir="auto">A <strong><code>greedy</code></strong> quantifier <strong>first</strong>, tries to repeat the token as <strong>MANY</strong> times as possible, and gradually GIVES UP matches, as the engine <strong>BACKTRACKS</strong>, to find an OVERALL match.</p>
</li>
<li>
<p dir="auto">A <strong><code>lazy</code></strong> quantifier, <strong>first</strong>, repeats the token as <strong>FEW</strong> times as required, and gradually EXPANDS the match, as the engine <strong>BACKTRACKS</strong> through the regex, to find an OVERALL match.</p>
</li>
<li>
<p dir="auto">A <strong><code>possessive</code></strong> quantifier, <strong>first</strong>, tries to repeat the token as <strong>MANY</strong> times as possible , and :</p>
<ul>
<li>
<p dir="auto">IF the REMAINDER, of the regex, can be <strong>matched</strong> =&gt; An OVERALL match is found</p>
</li>
<li>
<p dir="auto">IF the REMAINDER, of the regex <strong>CANNOT</strong> be matched =&gt; The match attempt fails <strong>IMMEDIATELY</strong>, without trying any <strong>BACKTRACHING</strong> step, in order to get an OVERALL match !</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<p dir="auto">When I, first, wanted to add this <strong>reply</strong>, I was told, by <strong>Askinet</strong> that it could <strong>not</strong> add such a reply, which was considered as <strong>SPAM</strong> :-((</p>
<p dir="auto">Luckily, I could get it to work, by adding, <strong>little by little</strong>, a <strong>few</strong> lines of my <strong>original</strong> reply and clicking, <strong>each</strong> time, on the blue <strong>Submit</strong> button !</p>
<p dir="auto">I, finally, succeeded to get my <strong>complete</strong> original reply ! I, <strong>first</strong> thought that it worries about <strong>special</strong> characters or the <strong>links</strong> or the <strong>HTML</strong> code. But, as the <strong>present</strong> reply contents seem <strong>identical</strong> to my <strong>original</strong> contents, except for building up the reply, in <strong>some</strong> steps, I don’t see what disturbed <strong>Askinet</strong> site, leading to the <strong>SPAM</strong> declaration !</p>
<p dir="auto">Anyway, if such a problem occurs to you, just try to <strong>split</strong> your reply in some parts, putting them  <strong>one after another</strong>, on our forum ! Click on the <strong>vertical three dots</strong> symbol, on the <strong>right</strong> part of the screen and choose the <strong>Edit</strong> option</p>
]]></description><link>https://community.notepad-plus-plus.org/post/18070</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18070</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 24 Sep 2016 19:49:59 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Thu, 22 Sep 2016 11:30:11 GMT]]></title><description><![CDATA[<p dir="auto">Google is a useful tool, you’d be surprised at the amount of information you can obtain from it.  For instance, here’s something on the topic that I quickly found that explains it pretty well:<br />
<a href="http://stackoverflow.com/questions/2301285/what-do-lazy-and-greedy-mean-in-the-context-of-regular-expressions" rel="nofollow ugc">http://stackoverflow.com/questions/2301285/what-do-lazy-and-greedy-mean-in-the-context-of-regular-expressions</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/18004</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18004</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Thu, 22 Sep 2016 11:30:11 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Thu, 22 Sep 2016 10:07:06 GMT]]></title><description><![CDATA[<p dir="auto">hello Guy. Yes, works. But I don’t understand what is the difference between “lazy quantifier” and “greedy quantifier” ?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/18000</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/18000</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Thu, 22 Sep 2016 10:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Wed, 21 Sep 2016 20:58:03 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <strong>Vasile</strong>,</p>
<p dir="auto">I would like to raise <strong>four</strong> points :</p>
<ul>
<li>
<p dir="auto"><strong>1)</strong> You’re <strong>right</strong> about adding the <strong><code>\b</code></strong> assertion, which ensures that the starting boundary is the <strong>beginning</strong> of a word and the <strong>ending</strong> boundary is an <strong>end</strong> of a word ! BTW, the expressions <strong><code>WORD_A</code></strong> and <strong><code>WORD_B</code></strong> should be renamed <strong><code>STRING_A</code></strong> and <strong><code>STRING_B</code></strong> :-))</p>
</li>
<li>
<p dir="auto"><strong>2)</strong> It’s also <strong>safer</strong> to use the syntax <strong><code>\W+</code></strong> which stands for <strong>any NON-word</strong> character(s) between words, instead of my syntax <strong><code>\h+</code></strong> which, only, refers to <strong>horizontal blank</strong> characters ( Just think about the simple string “Word1—Word2” ! )</p>
</li>
</ul>
<p dir="auto">So, thanks to the <strong><code>\b</code></strong> assertions and the <strong>NON-word</strong> characters <strong><code>\W+</code></strong>, the expressions <strong><code>STRING_A</code></strong> and <strong><code>STRING_B</code></strong> matched, are necessarily, <strong>true</strong> words :-))</p>
<ul>
<li>
<p dir="auto"><strong>3)</strong> Seemingly, your prefer to <strong>include</strong> the two boundaries <strong><code>STRING_A</code></strong> and <strong><code>STRING_B</code></strong>, in the <strong>selection</strong>. And I ,also, noticed that you use a <strong>non-capturing</strong> group : for a six-words length, it’s probably <strong>useless</strong>. But, generally speaking, it’s a <strong>good</strong> practice to do so, as the regex engine does <strong>not</strong> need to <strong>store</strong> the value of the group. This can <strong>increase</strong> the S/R speed, <strong>significantly</strong>, in some cases :-))</p>
</li>
<li>
<p dir="auto"><strong>4)</strong> Finally, your regex contains a <strong>lazy</strong> quantifier <strong><code>{...}?</code></strong>, to be sure that you’ll always get the <strong>shortest</strong> string , which satisfies the <strong>whole</strong> regex, when using the <strong><code>{n,}</code></strong> or <strong><code>{n,m}</code></strong> quantifiers. However, the regex, given in my <strong>previous</strong> post, does <strong>not</strong> matter about <strong>lazyness</strong> or <strong>greediness</strong> ! Indeed, as the words, between <strong><code>STRING_A</code></strong> and <strong><code>STRING_B</code></strong>, <strong>cannot</strong> be the boundaries, themselves, the <strong>two</strong> syntaxes give the <strong>same</strong> results :-))</p>
</li>
</ul>
<p dir="auto">Therefore, accordingly to <strong>your</strong> syntax, my regex, with the adding of the <strong>negative look-ahead</strong>, that I proposed in my <strong>last</strong> post, it, finally, gives the <strong>four new</strong> regexes, below :</p>
<ul>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:(?!STRING_A|STRING_B)\w+\W+){6}STRING_B\b</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:(?!STRING_A|STRING_B)\w+\W+){0,6}STRING_B\b</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:(?!STRING_A|STRING_B)\w+\W+){6,}STRING_B\b</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:(?!STRING_A|STRING_B)\w+\W+){6,12}STRING_B\b</code></strong></p>
</li>
</ul>
<hr />
<p dir="auto">So, according to the <strong>real</strong> text scanned, <strong>your</strong> regexes, or <strong>my</strong> version, will be used, <strong>preferably</strong> ! To get an idea of the <strong>differences</strong> of behaviour of these regexes, let’s consider the <strong>sample</strong> text, of <strong>9</strong> lines , below :</p>
<pre><code>STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu vbcvbcv STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu vbcvbcv ytyutyu STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu vbcvbcv ytyutyu ozerdfj STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu vbcvbcv ytyutyu ozerdfj dsfjqsd STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu vbcvbcv ytyutyu ozerdfj dsfjqsd xcvuo STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu vbcvbcv ytyutyu ozerdfj dsfjqsd xcvuo eroze STRING_B STRING_B STRING_B STRING_B STRING_B
STRING_A STRING_A STRING_A STRING_A dfsdf sdfsdf dfgdfg xcvwfv xcvxcv tyutyu vbcvbcv ytyutyu ozerdfj dsfjqsd xcvuo eroze dfodf STRING_B STRING_B STRING_B STRING_B STRING_B
</code></pre>
<p dir="auto">and apply, successively, the <strong>fourth</strong> case, ( the one with <strong><code>{n,m}</code></strong> quantifier ) of <strong>your</strong> and <strong>my</strong> regex, with, either, the <strong>lazy</strong> or <strong>greedy</strong> quantifier. That is to say, the searched regex :</p>
<ul>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:\w+\W+){6,12}?STRING_B\b</code></strong> , with the <strong>lazy</strong> quantifier <strong><code>{6,12}?</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:\w+\W+){6,12}STRING_B\b</code></strong> , with the <strong>greedy</strong> quantifier <strong><code>{6,12}</code></strong>`</p>
</li>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:(?!STRING_A|STRING_B)\w+\W+){6,12}?STRING_B\b</code></strong> , with the <strong>lazy</strong> quantifier <strong><code>{6,12}?</code></strong></p>
</li>
<li>
<p dir="auto"><strong><code>\bSTRING_A\W+(?:(?!STRING_A|STRING_B)\w+\W+){6,12}STRING_B\b</code></strong> , with the <strong>greedy</strong> quantifier <strong><code>{6,12}</code></strong>`</p>
</li>
</ul>
<p dir="auto">Observe the <strong>different</strong> ranges of the selection, as well as the <strong>beginning</strong> and the <strong>end</strong> of <strong>each</strong> selection ! As for my <strong>two</strong> regexes, they give exactly the <strong>same</strong> results, due to the <strong>negative look-ahead</strong> feature !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/17988</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/17988</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 21 Sep 2016 20:58:03 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Tue, 20 Sep 2016 03:57:29 GMT]]></title><description><![CDATA[<p dir="auto">I find a similar formula, that works fine. In this case WORD_A and WORD_B could be a group of words, not just singular words.</p>
<p dir="auto"><code>\bWORD_A\W+(?:\w+\W+){6}?WORD_B\b</code>  matches the gap, between the two words, WORD_A / WORD_B, separated by 6 words, exactly</p>
<p dir="auto"><code>\bWORD_A\W+(?:\w+\W+){0,6}?WORD_B\b</code>  matches the gap, between the two words, WORD_A / WORD_B, separated by a maximum of 6 words</p>
<p dir="auto"><code>\bWORD_A\W+(?:\w+\W+){6,}?WORD_B\b</code> matches the gap, between the two words, WORD_A / WORD_B, separated by a minimum of 6 words</p>
<p dir="auto"><code>\bWORD_A\W+(?:\w+\W+){6,12}?WORD_B\b</code> matches the gap, between the two words, WORD_A / WORD_B, separated by a minimum of 6 words and a maximum of 12</p>
]]></description><link>https://community.notepad-plus-plus.org/post/17966</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/17966</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Tue, 20 Sep 2016 03:57:29 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Mon, 19 Sep 2016 21:00:52 GMT]]></title><description><![CDATA[<p dir="auto">Hi <strong>Vasile</strong>,</p>
<p dir="auto">If we consider the <strong>sample</strong> text, below :</p>
<pre><code>bla bla WORD_A WORD_A WORD_A WORD_A WORD_A blah bla blah bla bla blah WORD_B WORD_B WORD_B WORD_B WORD_B blah blah…
</code></pre>
<p dir="auto">where the <strong>boundaries</strong> ( <strong><code>WORD_A</code></strong> and <strong><code>WORD_B</code></strong> ) are <strong>repeated</strong> and referring to the <strong>first</strong> of the <strong>four</strong> rexeges, described in my <strong>previous</strong> post, I would say :</p>
<p dir="auto"><strong><code>(?&lt;=WORD_A)(\h+(?!WORD_A|WORD_B)\w+){6}\h+(?=WORD_B)</code></strong></p>
<p dir="auto">If the <strong>quantifier</strong> is changed, for instance, into the values <strong><code>{5,9}</code></strong> or <strong><code>{0,7}</code></strong> or <strong><code>{4,}</code></strong>, it will be <strong>OK</strong>, as any of them covers the <strong>6</strong> number !</p>
<p dir="auto">On the contrary, if you choose, for instance, the quantifiers <strong><code>{2,5}</code></strong> or <strong><code>{8}</code></strong> or <strong><code>{7,}</code></strong> or <strong><code>{0,2}</code></strong>, it will <strong>NOT</strong> match anything in the <strong>subject</strong> sentence !</p>
<p dir="auto"><strong>Note</strong> :</p>
<ul>
<li>The syntax <strong><code>(?!WORD_A|WORD_B)</code></strong>, placed just before the <strong><code>\w+</code></strong> regex ( = a <strong>single</strong> word ), is a <strong>negative look-ahead</strong> that ensures that the <strong>found six</strong> words, between the <strong>two</strong> boundaries, <strong><code>WORD_A</code></strong> and <strong><code>WORD_B</code></strong>, are <strong>different</strong> from the <strong>two</strong> boundaries !</li>
</ul>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/17959</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/17959</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 19 Sep 2016 21:00:52 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Sun, 18 Sep 2016 13:59:34 GMT]]></title><description><![CDATA[<p dir="auto">hello Guy, works, but in the case I have 2 or more instances of WORD_A , and more instances of WORD_2. For example:</p>
<p dir="auto">bla bla <code>WORD_A_1</code> <code>WORD_A_2</code> blah bla blah bla bla blah <code>WORD_B_1</code> <code>WORD_B_1</code> blah blah…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/17949</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/17949</guid><dc:creator><![CDATA[Vasile Caraus]]></dc:creator><pubDate>Sun, 18 Sep 2016 13:59:34 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Wed, 14 Sep 2016 20:50:27 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <strong>Vasile</strong>,</p>
<p dir="auto">As it’s impossible to get <strong>broken</strong> selections, while searching, I just select <strong>all</strong> the range of characters, between <strong><code>WORD_A</code></strong> and <strong><code>WORD_B</code></strong>. By this means, it’s quite easy to, <strong>both</strong>, notice the <strong>gap</strong> of the <strong>six</strong> words  and the two <strong>delimiter</strong> words !</p>
<p dir="auto">So I propose <strong>four</strong> simple regexes :</p>
<ul>
<li>
<p dir="auto"><strong><code>(?&lt;=WORD_A)(\h+\w+){6}\h+(?=WORD_B)</code></strong> matches the <strong>gap</strong>, between the <strong>two</strong> words, <strong><code>WORD_A</code></strong> / <strong><code>WORD_B</code></strong>, separated by <strong>6</strong> words, <strong>exactly</strong></p>
</li>
<li>
<p dir="auto"><strong><code>(?&lt;=WORD_A)(\h+\w+){0,6}\h+(?=WORD_B)</code></strong> matches the <strong>gap</strong>, between the <strong>two</strong> words, <strong><code>WORD_A</code></strong> / <strong><code>WORD_B</code></strong>, separated by a <strong>maximum</strong> of <strong>6</strong> words</p>
</li>
<li>
<p dir="auto"><strong><code>(?&lt;=WORD_A)(\h+\w+){6,}\h+(?=WORD_B)</code></strong> matches the <strong>gap</strong>, between the <strong>two</strong> words, <strong><code>WORD_A</code></strong> / <strong><code>WORD_B</code></strong>, separated by a <strong>minimum</strong> of <strong>6</strong> words</p>
</li>
<li>
<p dir="auto"><strong><code>(?&lt;=WORD_A)(\h+\w+){6,12}\h+(?=WORD_B)</code></strong> matches the <strong>gap</strong>, between the <strong>two</strong> words, <strong><code>WORD_A</code></strong> / <strong><code>WORD_B</code></strong>, separated by a <strong>minimum</strong> of <strong>6</strong> words and a <strong>maximum</strong> of <strong>12</strong> words</p>
</li>
</ul>
<p dir="auto">Of course, you may change the different <strong>numbers</strong>, by any <strong>other</strong> value !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/17917</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/17917</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 14 Sep 2016 20:50:27 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: search the nearest words at a maximum distance of 6 words on Wed, 14 Sep 2016 20:22:59 GMT]]></title><description><![CDATA[<p dir="auto">What have you tried?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/17916</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/17916</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Wed, 14 Sep 2016 20:22:59 GMT</pubDate></item></channel></rss>