Why can't swift 5.7 in toolchain find Regex?

286 Views Asked by At

I believe I'm running Swift 5.7 from the command line, and that Swift 5.7 should have the new Regex class and /.../ syntax. But It doesn't seem to.

I have the following Swift source "parse.swift". But Swift didn't seem to understand the Swift 5.7 /.../ syntax to indicate Regex (generated errors it shouldn't for legitimate regex pattern), so I tried a different approach and discovered it doesn't recognize the new Regex class itself.

let pattern = #"^ ,([A-Z][A-Z])([0-9][0-9]),(.*?),(.*?) "#
let regex = try! Regex(pattern)

$ swift parse.swift < somefile

parse.swift:3:18: error: cannot find 'Regex' in scope
let regex = try! Regex(pattern)
                 ^~~~~

Is there something I need to import or do differently?

This is the version it says I'm running:

$ swift --version

Apple Swift version 5.7-dev (LLVM eecf02df5133efe, Swift ad06e7d7251311a)
Target: arm64-apple-macosx12.0

I selected the 5.7 version of Swift by exporting the following from ~/.zshrc

export TOOLCHAINS=org.swift.57202206261a
export TOOLCHAIN_DIR=/Library/Developer/Toolchains/swift-5.7-DEVELOPMENT-SNAPSHOT-2022-06-26-a.xctoolchain
0

There are 0 best solutions below