RosettaCodeData/Task/Regular-expressions/Swift/regular-expressions-3.swift
2016-12-05 23:44:36 +01:00

8 lines
289 B
Swift

import Foundation
if let regex = NSRegularExpression(pattern: "string$", options: nil, error: nil) {
let str = "I am a string"
if let result = regex.firstMatchInString(str, options: nil, range: NSRange(location: 0, length: count(str.utf16))) {
println("Ends with 'string'")
}
}