<p>你可以用</p>
<pre class="lang-py prettyprint-override"><code>pattern=re.compile(r"\w*?(?:tion|ex|ph|ost|ast|ist)\w*")
pattern=re.compile(r"[a-zA-Z]*?(?:tion|ex|ph|ost|ast|ist)[a-zA-Z]*")
pattern=re.compile(r"[^\W\d_]*?(?:tion|ex|ph|ost|ast|ist)[^\W\d_]*")
</code></pre>
<p>正则表达式(请参见<a href="https://regex101.com/r/V59Ctl/1" rel="nofollow noreferrer">the regex demo</a>)匹配</p>
<ul>
<li><code>\w*?</code>-零个或更多但尽可能少的单词字符</li>
<li><code>(?:tion|ex|ph|ost|ast|ist)</code>-字符串之一</li>
<li><code>\w*</code>-零个或更多但尽可能多的单词字符</li>
</ul>
<p><code>[a-zA-Z]</code>部分将只匹配ASCII字母,<code>[^\W\d_]</code>将匹配任何Unicode字母</p>
<p>注意使用带有<code>re.findall</code>的非捕获组,否则,捕获的子字符串也将进入输出列表</p>
<p>如果只需要匹配字母单词,并且需要将它们作为整个单词进行匹配,请添加<a href="https://www.regular-expressions.info/wordboundaries.html" rel="nofollow noreferrer">word boundaries</a>,<code>r"\b[a-zA-Z]*?(?:tion|ex|ph|ost|ast|ist)[a-zA-Z]*\b"</code></p>
<p>见<a href="https://ideone.com/tsC0M9" rel="nofollow noreferrer">Python demo</a>:</p>
<pre class="lang-py prettyprint-override"><code>import re
def latin_ish_words(text):
import re
pattern=re.compile(r"\w*?(?:tion|ex|ph|ost|ast|ist)\w*")
return pattern.findall(text)
print(latin_ish_words("This functions as expected"))
# => ['functions', 'expected']
</code></pre>