正则替换特定字符

 let url = "http://image.xxxx.xxx/xxxx/xxxx/[email protected]"
 do
 {
         let expression = try NSRegularExpression(pattern: "@\\w+.webp", options: [])
          let newUrl = expression.stringByReplacingMatches(in: url, options: [], range: NSMakeRange(0, url.characters.count), withTemplate: "")
          mImageNode?.url = URL(string: newUrl)
 }
 catch
 {
                
 }

你可能感兴趣的:(正则替换特定字符)