Regex Zero Width Match Budget
Budget possible zero-width progression positions from explicit UTF-16 length and code-point widths; not an actual pattern match count.
Description
Budget possible zero-width progression positions from explicit UTF-16 length and code-point widths; not an actual pattern match count.
Zero-width match positions depend on whether iteration advances by UTF-16 code unit or Unicode code point. A length budget can compare both conventions.
When to use this tool
Budget possible zero-width progression positions from explicit UTF-16 length and code-point widths; not an actual pattern match count.
- Prepare the supplied length, unicodeCodePointLengths 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 length, unicodeCodePointLengths. 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.codeUnitPositions, result.unicodePositions. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Require length from 0 to 8,192 and supplied code-point lengths each one or two whose sum equals length. Return length plus one code-unit positions and code-point count plus one Unicode positions.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| length | length. | Integer from 0 to 8192 inclusive |
| unicodeCodePointLengths | unicode code point lengths. | List of finite numbers; at most 128 entries |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.codeUnitPositions | The code unit positions value under the stated formula or text convention. |
| result.unicodePositions | The unicode positions value under the stated formula or text convention. |
{
"input": {
"length": 3,
"unicodeCodePointLengths": [
1,
2
]
},
"output": {
"result": {
"codeUnitPositions": 4,
"unicodePositions": 3
}
}
} Limitations and assumptions
- The width list is caller supplied and locally limited to 128 entries. This does not run a regex or establish its actual matches or runtime.
- 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 Match Group Presence Table
Report explicit JSON match-group presence where null means unmatched and empty string means a present empty capture; ragged match groups are retained.
- Regex Capture Index Map
Map ECMAScript capture indexes, names and opening-parenthesis UTF-16 positions after runtime syntax validation; escaped/class parentheses are ignored.