I can reproduce the problem in a playground in Xcode 14A5228q on macOS 13 (22A5266r).
I moved the Regex declaration to a separate line to rule out a parsing problem in the compiler front-end:
let transaction = "DEBIT 03/05/2022 Doug's Dugout Dogs $33.27"
let r = /\s{2,}|\t/
let fragments = transaction.split(separator: r)
The error message Cannot convert value of type 'Regex<Substring>' to expected argument type 'String.Element' (aka 'Character') is shown for line 3.
Looks like String is missing a variant of split(separator:...) that accepts a Regex. There is no such function in the doc pages either.
Another problem I'm having with Regex in Xcode 14A5228q, is that the parsing of the compact notation fails in my Swift package project. That is, if I copy the above three lines from the playground into my project, there will be an error in line 2 because the compiler fails to recognize / as a Regex start token.
Topic:
Programming Languages
SubTopic:
Swift
Tags: