Consider this simple regex that is supposed to match anything but a semicolon:
import RegexBuilder
let regex = /[^;]/
if let match = "a".firstMatch(of: regex) {
print("\(match.output)")
}
As expected, running this prints "a". When I use the context menu action Refactor > Convert to Regex Builder, Xcode converts the above code into the following:
import RegexBuilder
let regex = Regex {
One(.anyOf(";"))
.inverted
}
if let match = "a".firstMatch(of: regex) {
print("\(match.output)")
}
This will not compile and gives the compiler error
Value of type 'One<CharacterClass.RegexOutput>' (aka 'One<Substring>') has no member 'inverted'
How can this RegexBuilder expression be fixed? I am mainly asking this because I would like to use the inverted function in a more complex example, but so far have been unable to make it work.