Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Regex in GSC: Can you exclude pages?

         

Neohippy

8:03 am on Apr 9, 2021 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hooray, we finally have regex in GSC!

But I wonder if I'm missing something... I don't want to INCLUDE all my brand keywords, I want to EXCLUDE them!

Does anyone know if there's any kind of operator we can use to exclude groups of keywords/pages using regex?

lammert

10:18 pm on Apr 11, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If Google follows the standard regex implementation, this should work:
^(?:(?!keyword1|keyword2).)*$
It uses a negative lookahead for the keywords. You can add more keywords by adding them to the center expression, separated by a pipe symbol.

If this doesn't work, Google probably programmed their GSC extension in the language Go or C++. Because these are programming languages which don't support the negative lookahead feature.

Neohippy

7:22 am on Apr 12, 2021 (gmt 0)

5+ Year Member Top Contributors Of The Month



Ah, thanks so much for the response! I gave that a go, but no joy unfortunately, so guess it must not support it yet :/ Good to know I'm not going mad at least, thanks again!

lammert

12:59 pm on Apr 12, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't expect the feature of negative keywords to be added in the future. Regex is a core library function in the programming environment used by the developers and if it doesn't support a specific syntax you are out of luck. I don't expect a Googler to rewrite a proven core library function with the only goal to serve a small percentage of an already small audience which uses GSC.

Maybe one of the other members here knows a way to express multiple negative keywords in a regular expression without using negative lookahead.