正则测试
正则表达式在线测试,返回匹配结果和捕获组
GET
https://api.tinyaii.cn/v1/regex
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| pattern | string | 必填 | 正则表达式 | [0-9]+ |
| text | string | 必填 | 待匹配文本 | abc123def456 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码 |
| is_match | bool | 是否匹配 |
| matches | array | 匹配结果列表 |
| captures | array | 捕获组列表 |
| match_count | int | 匹配数量 |
返回示例
{
"code": 200,
"data": {
"pattern": "[0-9]+",
"is_match": true,
"matches": [
"123",
"456"
],
"match_count": 2
}
}
调用示例
curl "https://api.tinyaii.cn/v1/regex?pattern=[0-9]+&text=abc123def456" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch("https://api.tinyaii.cn/v1/regex?pattern=[0-9]+&text=abc123def456", {
headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
console.log(await res.json());import requests
resp = requests.get(
"https://api.tinyaii.cn/v1/regex",
params={"pattern": "[0-9]+", "text": "abc123def456"},
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=10,
)
print(resp.json())把 YOUR_API_KEY 换成你的密钥即可直接运行。密钥只保存在你自己的设备上。