Regex case match fails to compile in Xcode 14.0 (14A309)

import RegexBuilder

switch "abc" {
case /\w+/:
    print("It's a word!")
}

Gives an error:

expression failed to parse:
error: x.xcplaygroundpage:7:6: error: expression pattern of type 'Regex<Substring>' cannot match values of type 'String'
case /\w+/:
     ^

x.xcplaygroundpage:7:6: note: overloads for '~=' exist with these partially matching parameter lists: (Substring, String)
case /\w+/:
     ^
Post not yet marked as solved Up vote post of nkalvi Down vote post of nkalvi
876 views
  • Same error in 14.1 beta (14B5024h) as well.

Add a Comment

Replies

I have the same issue on Version 14.0.1 (14A400)

This is still the case in Xcode 14.2 (Swift 5.7.2).

According to the WWDC 2022 video, "Swift Regex: Beyond the basics," (04:17) this is supposed to work... is it just an issue on our systems, or is the feature actually unimplemented?