# Regex Notes

## 1. Character Classes `[]`

* **Definition**: Matches any one character from a specified set.
* **Syntax**: `[abc]` matches `a`, `b`, or `c`.
* **Ranges**: `[0-9]` matches any digit (0 through 9).
* **Example**:
  * `[aeiou]` matches any vowel.
  * `[A-Za-z]` matches any letter (uppercase or lowercase).

## 2. Grouping `()`

* **Definition**: Groups part of a regex for applying quantifiers or capturing matched text.
* **Syntax**: `(abc)` matches the exact sequence "abc".
* **Alternation**: `(cat|dog)` matches either "cat" or "dog".
* **Example**:
  * `(abc)+` matches "abc" one or more times (e.g., `abc`, `abcabc`).

## 3. Quantifiers

* **Definition**: Specifies how many times the preceding element should be matched.
* **Common Quantifiers**:
  * `*` - Zero or more times.
  * `+` - One or more times.
  * `?` - Zero or one time.
  * `{n}` - Exactly `n` times.
  * `{n,}` - At least `n` times.
  * `{n,m}` - Between `n` and `m` times.
* **Example**:
  * `a*` matches zero or more `a`s.
  * `a+` matches one or more `a`s.
  * `\d{3}` matches exactly three digits (e.g., `123`).

## Combining Concepts

* **Example**:
  * `([A-Za-z]+)\s+([0-9]+)` matches a word followed by one or more spaces and then digits.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aloy.gitbook.io/notes/languages-frameworks/programming-languages/regex.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
