Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This question sounds interesting. I don't know <a href="/questions/tagged/php" class="post-tag" title="show questions tagged 'php'" rel="tag">php</a> but I decided to challenge myself to resolve it with <a href="/questions/tagged/python" class="post-tag" title="show questions tagged 'python'" rel="tag">python</a>, that I'm more used to it.</p> <pre><code>import regex s = r"This is an example text to explain the problem I am having with the regular expression" [elem for t in regex.findall(r'\m(?|(((\w{4,})\W+\w{3,})\W+\w{3,})|((\w{4,})\W+\w{3,})|(\w{4,}))', s, overlapped=True) for elem in t if elem != ''] </code></pre> <p>I've used the <code>regex</code> module and its <code>overlapped</code> option that begins next match from the character following the current one. The regular expression returns tuples like:</p> <pre><code>[('This', '', ''), ('example text', 'example', ''), ('text', '', ''), ('explain the problem', 'explain the', 'explain'), ('problem', '', ''), ('having with the', 'having with', 'having'), ('with the regular', 'with the', 'with'), ('regular expression', 'regular', ''), ('expression', '', '')] </code></pre> <p>So from there I do another loop to extract those fields that are not blank, that yields:</p> <pre><code>['This', 'example text', 'example', 'text', 'explain the problem', 'explain the', 'explain', 'problem', 'having with the', 'having with', 'having', 'with the regular', 'with the', 'with', 'regular expression', 'regular', 'expression'] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload