我的网址看起来像123456_https://example.com
我想删除_https:
部分之前的所有内容。最后,网址应该看起来像https://example.com
我怎样才能做到这一点?
答案 0 :(得分:0)
如果前缀始终是以下划线结尾的几个字符,则可以使用此正则表达式
let url = "123456_https://example.com"
let trimmedURL = url.replacingOccurrences(of: "^\\w+_", with: "", options: .regularExpression)
答案 1 :(得分:0)
如果您不知道如何使用正则表达式
,则可以执行此类操作%R