Advanced Regular Expressions - part 4

Hi,
I have one quick question. In part "Advanced Regular Expressions ", I am not sure whether I need to use a backslash () inside a set to escape special characters.

Screen Link:
https://app.dataquest.io/m/369/advanced-regular-expressions/4/counting-mentions-of-the-c-language

for example, in the code below, I want to exclude “dot and plus notation” from the characters following “C”. I am not sure which pattern I need to use.

My Code:

pattern1 = r"\b[Cc]\b[^\.\+]"   # with backslash before special characters
pattern2 = r"\b[Cc]\b[^.+]"     # without backslash before special characters

Thanks for helping with this question

Already answered here.

Thanks for your help and thorough explanation!

1 Like