99热99这里只有精品6国产,亚洲中文字幕在线天天更新,在线观看亚洲精品国产福利片 ,久久久久综合网

歡迎加入QQ討論群258996829

Swift 正則表達式類庫 Regex

發(fā)布時間:2016-07-03 22:54  回復(fù):0  查看:6954  感興趣:24  贊:0   最后回復(fù):2016-07-03 22:54  

Regex 是一個 Swift 正則表達式類庫。

示例代碼:

//創(chuàng)建
// Use `Regex.init(_:)` to build a regex from a static pattern

let greeting = Regex("hello (world|universe)")

// Use `Regex.init(string:)` to construct a regex from dynamic data, and
// gracefully handle invalid input

var validations: [String: Regex]

for (name, pattern) in config.loadValidations() {
  do {
    validations[name] = try Regex(string: pattern)
  } catch {
    print("error building validation \(name): \(error)")
  }
}


//匹配
if greeting.matches("hello universe!") {
  print("wow, you're friendly!")
}

相關(guān)開源代碼

您還未登錄,請先登錄

熱門帖子

最新帖子

?