The task was to write a regular expression that includes ‘C’ or ‘c’ and excludes ‘C++’ or ‘C.’
My Code:
pattern = r"\b[Cc][^+.]\b"
Solution Code:
pattern = r"\b[Cc]\b[^+.]"
I don’t understand why the boundaries need to exclude [^+.]
The task was to write a regular expression that includes ‘C’ or ‘c’ and excludes ‘C++’ or ‘C.’
My Code:
pattern = r"\b[Cc][^+.]\b"
Solution Code:
pattern = r"\b[Cc]\b[^+.]"
I don’t understand why the boundaries need to exclude [^+.]
+
is not a word.