Regex Tester API
Run a JavaScript regular expression against text: every match with its position and capture groups, an optional replacement result, and a plain-English explanation of the pattern. Runs are time-limited.
POST /api/v1/tools/regex-testerMCP regex_testerDeveloper ToolsTest JavaScript regular expressions live: highlight every match, inspect numbered and named capture groups, toggle flags and preview replacements in your browser.
Input
Send these as a JSON object. Unknown fields are rejected.
- pattern
- The pattern without slashes, e.g. (\d{4})-(\d{2})-(\d{2}). JavaScript (ECMAScript) syntax. (string, up to 2000 characters, required)
- flags
- Flags from "dgimsuvy", each at most once; g lists every match, without g only the first. (string, up to 8 characters, default "g")
- text
- The text to search (up to 50,000 characters). (string, up to 50000 characters, default "")
- replacement
- Optional replacement string ($1, $<name>, $& supported). When given, the replaced text is returned as replaced. (string, up to 10000 characters)
- maxMatches
- Most matches to return (1 to 1000). (integer, 1 to 1000, default 100)
- explain
- Include a plain-English explanation of each part of the pattern. (boolean, default true)
curl https://pithlab.com/api/v1/tools/regex-tester \n -H "Authorization: Bearer $PITHLAB_KEY" \n -H "Content-Type: application/json" \n -d '{"pattern":"(?<year>\\d{4})-(?<month>\\d{2})","flags":"g","text":"Released 2024-03, updated 2025-11.","replacement":"$<month>/$<year>"}'Example response
{
"ok": true,
"result": {
"matchCount": 2,
"truncated": false,
"matches": [
{
"index": 9,
"end": 16,
"text": "2024-03",
"groups": [
"2024",
"03"
],
"named": {
"year": "2024",
"month": "03"
}
},
{
"index": 26,
"end": 33,
"text": "2025-11",
"groups": [
"2025",
"11"
],
"named": {
"year": "2025",
"month": "11"
}
}
],
"replaced": "Released 03/2024, updated 11/2025."
}
}