Still not understanding Q5 regex explanation

I’m on part 5 of the Advanced Regex section and even though I’ve looked at the other existing threads on the topic, the answer still isn’t clear to me. The given answer doesn’t select the correct value even if it is at the end of the sentence.

We’re told to:
Exclude instances where it is followed by a . or + character, without removing instances where the match occurs at the end of the sentence.

The regex given as the answer is

pattern =r'(?<!Series\s)\b[Cc]\b((?![+.])|\.$)'

However, when I try it in RegExr, I get the following:
Screenshot 2021-09-17 201845

Why isn’t it matching the ‘C.’ when it shows up at the end of the sentence? I know that the period (.) is technically the last character in the sentence, but I’m failing to understand how this particular example works. Any help would be appreciated.

It does match. It looks like regexr.com only displays the first match when there are multiple matches:

image

I’d use regex101.com, if I were you. It allows Python as an option, while regexr.com does not.

Well dang. I feel silly now. Thank you very much.

1 Like