swiftlang / swiftlang/swift-experimental-string-processing
Regex compare not case-insensitive for single optional characters
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 308
- Forks
- 52
- Avg merge
- 12h 45m
- Merged PRs (30d)
- 2
Description
Description
When a case-insensitive regex contains an optional character, the optional character is not compared in a case-insensitive fashion. For instance, the regex /ab?c/.ignoresCase() will match "AbC", but will fail to match "ABC".
Reproduction
let pattern = /ab?c/.ignoresCase()
let tests = ["abc", "Abc", "ABC", "ac", "AC", "AbC", "aBc"]
for test in tests {
let matched = test.wholeMatch(of: pattern) != nil
print("\(matched ? "pass" : "FAIL"): \(test)")
}
when that code is run in a playground, the following is output:
pass: abc
pass: Abc
FAIL: ABC
pass: ac
pass: AC
pass: AbC
FAIL: aBc
Expected behavior
I expect all of those tests to pass.
Environment
% swiftc --version
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Additional information
Note that the tests do all pass for this form: /a(b)?c/.ignoresCase()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Swift reproduction in the issue, comparing /ab?c/.ignoresCase() with the working /a(b)?c/.ignoresCase() form. Trace how an optional single character is compiled and matched, then verify that all listed inputs pass, including ABC and aBc; the issue names no source file or test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100