Skip to content

Regular expressions: "invalid bound for character class range" despite "\x{...}" formulation #82424

Open
@stefanspringer1

Description

@stefanspringer1

Describe the bug

Regular expressions may result in the compilation error "invalid bound for character class range" despite using the "\x{...}" formulation.

That happens for combining characters, but also happens for some letter like symbols.

To Reproduce

 _ = "abc".contains(/[\x{33D}-\x{344}]/) // compilation error: Cannot parse regular expression: invalid bound for character

Expected behavior
For codepoints referenced by the "\x{...}" syntax, the mentioned error should not occur (at least some other regex tools accept them in the example above).

Configuration (please complete the following information):

  • Swift Version: swiftlang-6.1.2.1.2 clang-1700.0.13.5)
  • OS: macOS
  • OS Version: 15.5

Regression information:
Always have been a problem.

Additional context
If the codepoints in the range are all listed separately, the regex expression is accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.regex literalsFeature → expressions → literals: regex literals

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions