跳转到内容
POST AI agent ready /v1/regex/test

正则表达式测试 API - 免费模式匹配器

将带有可选标志的正则表达式模式应用于测试字符串,并返回所有匹配项及其位置和捕获的组。 支持 g、i、m、s 和 u 标志。

Parameters

stringrequired

The regular expression pattern (without delimiters).

string

Regex flags (e.g., "gi" for global case-insensitive).

stringrequired

The string to test the pattern against.

Code examples

curl -X POST https://api.botoi.com/v1/regex/test \
  -H "Content-Type: application/json" \
  -d '{"pattern":"\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b","flags":"gi","testString":"Contact support@botoi.com or sales@botoi.com"}'

When to use this API

部署前调试正则表达式模式

在将复杂模式嵌入到应用程序代码中之前,根据示例数据测试复杂模式以验证匹配并捕获组。

在无代码工具中验证输入模式

让用户将自定义验证规则定义为正则表达式模式,并根据应用程序中的示例输入对其进行测试。

从非结构化文本中提取结构化数据

使用捕获组从日志行或抓取的内容中提取电话号码、日期或 ID。

Frequently asked questions

支持哪些正则表达式标志?
API 支持 g(全局)、i(不区分大小写)、m(多行)、s(dotAll)和 u(unicode)标志。
如何返回捕获组?
每个匹配都包含一个 groups 数组,其中包含模式中任何带括号的捕获组的值。
复杂模式有超时吗?
是的。 执行时间超过 5 秒的模式将被终止以防止 ReDoS。 如果达到此限制,请简化您的模式。
我需要转义模式中的反斜杠吗?
将模式作为 JSON 字符串发送,因此反斜杠需要双转义(例如,\\b 表示单词边界)。

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.