RE2 Reference GSC & BigQuery Compatible

RE2 Regex Filter Cookbook for Search Console

A collection of battle-tested regular expression patterns built specifically for Google Search Console’s RE2 syntax engine.

RE2 Engine Technical Specifications

Google Search Console evaluates regex filters using Google’s open-source RE2 regular expression engine. RE2 is engineered to run in guaranteed linear time O(n) to eliminate catastrophic backtracking.

✓ Fully Supported:

Character classes, word boundaries (\b), repetitions ({n,m}), alternations (|), and case-insensitive flags ((?i)).

✗ Not Supported by RE2:

Lookarounds ((?=...), (?!...)), backreferences (\1), and possessive quantifiers will cause filter errors.

Tested RE2 Filter Patterns

Brand vs. Non-Brand Segmentation

Brand Variations & Common Typos

Queries matching regex
(?i)(naben|nabin|shrestha|nabenshrestha)

Matches any search query containing common spelling variants of the brand name, regardless of capitalization. Use "Queries not matching regex" to isolate pure non-brand organic discovery.

Primary Objective: Brand equity monitoring & isolating non-branded SEO acquisition.
Search Intent & Query Classification

Informational Question Queries

Queries matching regex
(?i)^(who|what|where|when|why|how|can|is|are|does|do|should|would)\b

Matches queries that start with classic interrogative words, capturing high-intent educational questions ideal for featured snippets and documentation.

Primary Objective: Content roadmap prioritization and identifying FAQ schema targets.
Search Intent & Query Classification

Commercial & High-Intent Comparison

Queries matching regex
(?i)\b(vs|versus|compare|alternative|best|review|pricing|cost|worth it)\b

Captures queries where searchers are evaluating options, comparing solutions, or checking costs prior to conversion.

Primary Objective: Product landing page optimization and commercial content strategy.
Query Length & Long-Tail Analysis

Long-Tail Queries (4+ Words)

Queries matching regex
^([^ ]+ ){3,}[^ ]+$

Identifies highly specific long-tail queries consisting of 4 or more space-separated words. These queries typically have lower volume but higher conversion intent.

Primary Objective: Long-tail keyword extraction and conversational search analysis.
Query Length & Long-Tail Analysis

Short Head-Terms (1 to 2 Words)

Queries matching regex
^[^ ]+( [^ ]+)?$

Filters search queries that contain only 1 or 2 words. Useful for monitoring high-competition head terms and broad industry keywords.

Primary Objective: High-level category ranking audits and competitive benchmarking.
URL Path & Page Filtering

Specific Directory Isolation

URLs matching regex
^https?://[^/]+/handbook/module-[0-9]+/.*

Isolates all URLs that reside within specific module directories while excluding homepage, overview pages, or unrelated directories.

Primary Objective: Section-by-section technical performance analysis.
URL Path & Page Filtering

Numeric IDs / Paginated URLs

URLs matching regex
.*(/page/[0-9]+|\?p=[0-9]+|-[0-9]{5,}\.html).*

Captures paginated URL variations or items indexed with dynamic numeric identifiers.

Primary Objective: Crawl bloat audits and pagination consolidation.
Striking Distance Discovery

Problem-Solving & Debugging Queries

Queries matching regex
(?i)\b(error|fix|solved|bug|failed|not working|crash|issue|missing)\b

Filters technical troubleshooting queries where users are actively trying to solve an operational error.

Primary Objective: Building high-converting troubleshooting guides and technical documentation.

Common RE2 Gotchas in Search Console

  • Case Sensitivity by Default: Search queries in GSC are stored in lowercase, but URLs are case-sensitive. Always prepend (?i) when matching queries to ensure variations don't get accidentally excluded.
  • No Need to Escape Forward Slashes: In JavaScript regex literals you must escape slashes (\/). In GSC filter inputs, you write clean slashes (/handbook/module-1/).
  • Partial Matching: By default, RE2 in GSC looks for the pattern anywhere in the string unless anchored with ^ (start of string) or $ (end of string).
Deep dive available in curriculum: Module 3 Lesson 2: Regex Mastery →