My Profile Photo

Hao's Keeper


A blog to place memos


Swift Regex Replace

var str = "123ABC456 789abc012"
_ = str.replacingOccurrences(of: "[a-zA-Z]", with: "-", options: .regularExpress, range: nil)

// output
// 123---456 789---012