Just an idea (untested):
struct Result: Codable {
let word: String?
let number: Int?
}
let regex = Regex(#"\d+(?<\#(.word)>[a-z]+)(?<\#(.number)>\d+)"#, type: Result.self)
let groups = regex.firstMatch(in: "123unicorn456")?.namedGroups
print(groups.word)
//=> Optional("unicorn")
print(groups.number)
//=> Optional(456)
// ^ Int
Feedback wanted!
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too