ASCII Character Class Parser
Parse bounded ASCII bracket classes with literal characters, ordered ranges and \xHH escapes only; complements are relative to 0–127.
Description
Parse bounded ASCII bracket classes with literal characters, ordered ranges and \xHH escapes only; complements are relative to 0–127.
A restricted ASCII regex class can be expanded into its literal code membership. This parser deliberately supports a small grammar.
When to use this tool
Parse bounded ASCII bracket classes with literal characters, ordered ranges and \xHH escapes only; complements are relative to 0–127.
- 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.codes. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Require brackets, optionally a leading negation caret, and ASCII literals, ordered ranges or two-digit hexadecimal escapes. Expand and deduplicate codes; negation complements within 0 through 127.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.codes | The codes list in the ordering and representation described above. |
{
"input": {
"pattern": "[a-c\\x2d]"
},
"output": {
"result": {
"codes": [
45,
97,
98,
99
]
}
}
} Limitations and assumptions
- Shorthand classes, Unicode escapes and set operators are unsupported. Reserved class characters require the supported hex spelling; this is not a general ECMAScript class parser.
- 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
- ASCII Character Class Complement
Complement an explicit code set against ASCII 0–127 only, not Unicode or a regex engine’s complete character universe.
- ASCII Character Class Formatter
Format a positive ASCII character class using explicit two-digit hexadecimal escapes, avoiding metacharacter ambiguity.