Skip to content

Off by one error for Repeat(...) #478

Closed
@hamishknight

Description

@hamishknight

From https://forums.swift.org/t/regexbuilder-repeat-range-off-by-one/58079:

import RegexBuilder

let s = "aaaaaaaaaa"
let rx = Regex {
    Repeat(0...1) { "a" }
}
s.firstMatch(of: rx) // ["aa"]

Looks like we're converting 0...1 to 0..<2 and then initializing a quantification .upToN without adjusting the upper bound down.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions