# Regular expressions (regex)

Category: [Analytics & Measurement](https://seo-geo-glossary.com/en/glossary/category/analytics-measurement/) › [Search Console](https://seo-geo-glossary.com/en/glossary/category/analytics-measurement/search-console/) · Also known as: regex, regexp, regular expression

A **regular expression** (regex) is a text pattern that describes a set of strings. A tool compares the pattern with a text and reports whether and where it matches. In SEO, regex is mainly used to filter or group URLs and search queries in tools such as Search Console, Google Analytics, Looker Studio and crawlers.

## How do regular expressions work?

A pattern combines literal characters with special symbols. The most useful ones in RE2, the engine developed by Google, are:

| Symbol | Meaning |
|---|---|
| `.` | any single character |
| `*` `+` `?` | zero or more, one or more, zero or one of the preceding item |
| `^` `$` | start and end of the text |
| `[abc]` | one character from the set |
| `(a\|b)` | a or b |
| `\d` `\w` | a digit, a word character |
| `{n,m}` | between n and m repetitions |

Characters like `.` `?` `(` and `|` have a special meaning. A literal dot needs a backslash (`\.`). RE2 does not support backreferences and lookahead or lookbehind, so patterns copied from other languages may fail. The Search Console API names RE2 syntax for its regex filter operators (`includingRegex`, `excludingRegex`), and the filter in the interface reportedly uses it as well.

## Example

Filtering URLs for all blog posts from 2025 or 2026:

```
^https://example\.com/blog/(2025|2026)/.+
```

Filtering queries that contain a brand name in two spellings:

```
(acme ?shop|acmeshop)
```

## Common mistakes

- **Unescaped dot.** `example.com` also matches `exampleXcom`.
- **Missing anchors.** Without `^` and `$`, a pattern matches anywhere inside the text.
- **Patterns from other languages.** Lookahead works in JavaScript and not in RE2.
- **Case sensitivity.** Check whether the tool treats `Shoes` and `shoes` alike. With RE2, the flag `(?i)` switches case-insensitive matching on.

## Related terms

- [Google Search Console](https://seo-geo-glossary.com/en/glossary/google-search-console/index.md)
- [URL](https://seo-geo-glossary.com/en/glossary/url/index.md)
- [URL parameters](https://seo-geo-glossary.com/en/glossary/url-parameters/index.md)

## Sources

- [RE2 Syntax – GitHub google/re2 wiki](https://github.com/google/re2/wiki/Syntax)
- [Regular expressions – JavaScript – MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions)
- [Regular-Expressions.info](https://www.regular-expressions.info/)
- [Search Analytics: query – Search Console API (includingRegex, excludingRegex)](https://developers.google.com/webmaster-tools/v1/searchanalytics/query)

---

Last updated: October 7, 2026
URL: https://seo-geo-glossary.com/en/glossary/regular-expressions/
