Regex Capture Index Map
Map ECMAScript capture indexes, names and opening-parenthesis UTF-16 positions after runtime syntax validation; escaped/class parentheses are ignored.
Description
Map ECMAScript capture indexes, names and opening-parenthesis UTF-16 positions after runtime syntax validation; escaped/class parentheses are ignored.
Capture indexes follow opening-parenthesis order, while noncapturing groups and lookarounds do not allocate an index.
When to use this tool
Map ECMAScript capture indexes, names and opening-parenthesis UTF-16 positions after runtime syntax validation; escaped/class parentheses are ignored.
- Prepare the supplied pattern fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter pattern. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.captures. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
First compile pattern with the local ECMAScript engine without flags. Scan escaped characters and character classes, then record ordinary capturing parentheses and named groups with one-based index, name or null, and UTF-16 opening position.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| pattern | pattern. | Text; at most 8,192 UTF-16 code units, subject to the grammar above |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.captures | The captures list in the ordering and representation described above. |
{
"input": {
"pattern": "(a)(?:b)(?\u003cname\u003ec)"
},
"output": {
"result": {
"captures": [
{
"index": 1,
"name": null,
"position": 0
},
{
"index": 2,
"name": "name",
"position": 8
}
]
}
}
} Limitations and assumptions
- This is a bounded source scanner after syntax validation, not a full regex AST parser. Flag-dependent syntax, especially Unicode-set classes, is outside its scope.
- All declared input fields are required and unexpected top-level fields are rejected. Numbers must be finite; lists are limited to 128 entries and ordinary text fields to 8,192 UTF-16 code units, with tighter limits where stated.
- JSON text inputs must parse within bounded nesting and size limits. Numeric outputs outside the safe finite range are rejected; large exact integer results use decimal strings. Indexes and half-open spans are zero-based unless a rank is explicitly described as one-based.
Alternative or Complementary methods
Compile generated pattern sources with explicitly chosen flags and test them on bounded representative text. Pattern sources, replacement strings and JSON string spellings require different escaping conventions.
References
Similar or alternative tools
- Regex Flag Set Audit
Audit syntactic ECMAScript flag names, duplicates and mutually exclusive u/v flags; does not assert every flag is supported by the installed runtime.
- Literal Full Token Pattern Builder
Build a literal full-string ECMAScript pattern with a strict end assertion, avoiding dollar-anchor final-newline acceptance; assumes no multiline flag.