print words between two particular words in a given string
<p>if one particular word does not end with another particular word, leave it. here is my string:</p>

<pre><code>x = 'john got shot dead. john with his .... ? , john got killed or died in 1990. john with his wife dead or died'
</code></pre>

<p>i want to print and count all words between <code>john</code> and <code>dead or death or died.</code>
if <code>john</code> does not end with any of the <code>died or dead or death</code> words. leave it. start again with john word.</p>

<p>my code :</p>

<pre><code>x = re.sub(r'[^\w]', ' ', x)  # removed all dots, commas, special symbols

for i in re.findall(r'(?&lt;=john)' + '(.*?)' + '(?=dead|died|death)', x):
    print i
    print len([word for word in i.split()])
</code></pre>

<p>my output:</p>

<pre><code> got shot 
2
 with his          john got killed or 
6
 with his wife 
3
</code></pre>

<p>output which i want:</p>

<pre><code>got shot
2
got killed or
3
with his wife
3
</code></pre>

<p>i don't know where i am doing mistake. 
it is just a sample input. i have to check with 20,000 inputs at a time.</p>