Regex tester
Test a regular expression against text and see every match with its position and groups.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/regex-test \
-H 'Content-Type: application/json' \
-d '{"input":{"pattern":"(?P<year>\\d{4})-(\\d{2})","text":"From 2024-01 to 2025-12"}}'
import json, urllib.request
body = {'input': {'pattern': '(?P<year>\\d{4})-(\\d{2})', 'text': 'From 2024-01 to 2025-12'}}
request = urllib.request.Request("https://setget.net/v1/tools/regex-test", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/regex-test", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"pattern":"(?P<year>\\d{4})-(\\d{2})","text":"From 2024-01 to 2025-12"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "regex-test",
"input": {
"pattern": "(?P<year>\\d{4})-(\\d{2})",
"text": "From 2024-01 to 2025-12"
}
}
{
"input": {
"pattern": "(?P<year>\\d{4})-(\\d{2})",
"text": "From 2024-01 to 2025-12"
}
}
Endpoint: POST /v1/tools/regex-test. Over MCP: run_tool with slug: "regex-test".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
pattern |
string | yes | The regular expression (Python syntax). |
text |
string | yes | The text to search. |
flags |
string | no | Letters that switch options on: i (ignore case), m (^ and $ match at each line), s (dot matches line breaks), x (allow spaces and comments). Default: "". |
Examples
Input
{
"pattern": "(?P<year>\\d{4})-(\\d{2})",
"text": "From 2024-01 to 2025-12"
}Result
{
"matched": true,
"count": 2,
"truncated": false,
"matches": [
{
"match": "2024-01",
"start": 5,
"end": 12,
"groups": [
"2024",
"01"
],
"named": {
"year": "2024"
}
},
{
"match": "2025-12",
"start": 16,
"end": 23,
"groups": [
"2025",
"12"
],
"named": {
"year": "2025"
}
}
]
}Ignoring case
Input
{
"pattern": "^hello",
"text": "Hello there",
"flags": "i"
}Result
{
"matched": true,
"count": 1,
"truncated": false,
"matches": [
{
"match": "Hello",
"start": 0,
"end": 5,
"groups": [],
"named": {}
}
]
}Questions
- Which regex syntax is this?
- Python's. It is close to PCRE and JavaScript, with named groups written (?P<name>...).
- How are positions counted?
- "start" and "end" count characters from 0. "end" is the position just after the match.
- Why is a group null?
- That group is optional and took no part in the match.
Related tools
- Regex extractorPull every match of a regular expression out of text as a simple list, or just one capture group.
regex-extract - Regex replaceReplace every match of a regular expression, with backreferences such as \1 in the replacement.
regex-replace - Find and replaceReplace every occurrence of a word or phrase in text, exactly as typed, with a count of the changes.
find-replace - Apply a patchApply a unified diff to a text and get the patched result, with clear errors when a hunk does not fit.
patch-apply - Case converterConvert text between lower, UPPER, Title, Sentence, camelCase, PascalCase, snake_case, kebab-case and more.
case-convert - Escape and unescape textEscape or unescape text for HTML, URLs, JSON strings, shell commands, regular expressions and CSV fields.
escape-unescape