let s: プログラミング言語? = Swift[2]
■ このスレッドは過去ログ倉庫に格納されています
0057名称未設定
2014/08/26(火) 00:26:45.76ID:2UMJDwPt0https://github.com/VerbalExpressions/SwiftVerbalExpressions
// 例 Create an example of how to test for correctly formed URLs (注:全角空白使用)
let tester = VerEx()
.startOfLine()
.then("http")
.maybe("s")
.then("://")
.maybe("www")
.anythingBut(" ")
.endOfLine()
// Create an example URL
let testMe = "https://www.google.com"
// Use =~ operator
if testMe =~ tester {
println("We have a correct URL") // This output will fire
}
else {
println("The URL is incorrect")
}
println(tester) // Outputs the actual expression used: "^(?:http)(?:s)?(?::\/\/)(?:www)?(?:[^
//Shorthand for string replace:
let result2 = VerEx().find("red").replace("We have a red house", with: "blue")
■ このスレッドは過去ログ倉庫に格納されています