> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/chinese/guan-li-yu-she-zhi/settings/global-settings/document-types/regex/purpose-and-use.md).

# 用途

Regex 是“正则表达式”（Regular Expressions）的简称，是一种非常强大的文本模式识别方法。它可以在文本中搜索特定字符串或模式，具有高度的灵活性和精确性。

**在从文档等结构化文本格式中提取数据时，Regex 因以下几个原因发挥着关键作用：**

**精确的模式识别：**

* Regex 可用于定义要在文本中搜索的精确模式。
* 当要提取的数据遵循特定格式或结构时，这一点尤其有用。

**灵活适配：**

* Regex 提供了丰富的运算符和结构，可以定义复杂模式，以提取不同格式和变体的数据。
* 这使其能够灵活适配不同的文档结构。

**高效处理：**

* Regex 可高效处理大量文本，因为模式搜索通常速度很快，即使是大型文本文档，也能在可接受的时间内完成搜索。

**自动化：**

* Regex 可用于脚本和程序，以自动化提取流程。
* 当需要处理大量文档时，这一点尤其有用，因为手动提取数据耗时且容易出错。

**验证和清理：**

* 除了提取数据，Regex 还可用于验证和清理文本。
* 通过定义模式，可以识别并删除不需要的字符串，从而让数据更加干净、一致。

总的来说，使用 Regex 能有效分析结构化文本格式，并准确、高效地提取数据，因此在数据分析、文本处理、信息提取和机器学习等各种应用场景中都非常有用。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docbits.com/chinese/guan-li-yu-she-zhi/settings/global-settings/document-types/regex/purpose-and-use.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
