Python Regex for ignoring a sentence with two consecutive upper case letters
<p>I have a simple problem at hand to ignore the sentences that contain two or more consecutive capital letters and many more grammar rules .</p>

<p><strong>Issue:</strong> By the definition the regex should not match the string <code>'This is something with two CAPS.'</code> , but it does match.</p>

<p><strong>Code:</strong> </p>

<pre><code>''' Check if a given sentence conforms to given grammar rules

    $ Rules
        * Sentence must start with a Uppercase character (e.g. Noun/ I/ We/ He etc.)
        * Then lowercase character follows.
        * There must be spaces between words.
        * Then the sentence must end with a full stop(.) after a word.
        * Two continuous spaces are not allowed.
        * Two continuous upper case characters are not allowed.
        * However the sentence can end after an upper case character.
'''

import re


# Returns true if sentence follows these rules else returns false
def check_sentence(sentence):
    checker = re.compile(r"^((^(?![A-Z][A-Z]+))([A-Z][a-z]+)(\s\w+)+\.$)")
    return checker.match(sentence)

print(check_sentence('This is something with two CAPS.'))
</code></pre>

<p><strong>Output:</strong></p>

<pre><code>&lt;_sre.SRE_Match object; span=(0, 32), match='This is something with two CAPS.'&gt;
</code></pre>

<p>Your negative lookahead is only applying to the beginning of the string being tested. </p>

<p>2nd Capturing Group <code>(^(?![A-Z][A-Z]+))</code></p>

<p><code>^</code> asserts position at start of the string</p>

<p>Negative Lookahead <code>(?![A-Z][A-Z]+)</code></p>

<p><code>"This will NOT fail."</code></p>

<p><code>"THIS will fail."</code></p>

python regex python-3.x