擅长:python、mysql、java
<p>您可以使用带有否定前瞻断言的正则表达式来查找“mato\u grosso”后面不跟“do\u sul”的匹配项。例如:</p>
<pre><code>re.match('mato_grosso_(?!do_sul)', 'mato_grosso_2000_test.csv')
re.match('mato_grosso_(?!do_sul)', 'mato_grosso_do_sul_2000_test.csv')
</code></pre>
<p>这会为第一个示例找到匹配项,但不会为第二个示例找到匹配项。你知道吗</p>
<p>Python<a href="https://docs.python.org/2/library/re.html" rel="nofollow noreferrer">re module</a>文档详细讨论了正则表达式语法。做一个“消极的前瞻性”寻找更多的细节。你知道吗</p>