Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
let str = "I am a string"
|
||||
if let range = str.rangeOfString("string$", options: .RegularExpressionSearch) {
|
||||
println("Ends with 'string'")
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import Foundation
|
||||
|
||||
let orig = "I am the original string"
|
||||
let result = orig.stringByReplacingOccurrencesOfString("original", withString: "modified", options: .RegularExpressionSearch)
|
||||
println(result)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
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'")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
for x in regex.matchesInString(str, options: nil, range: NSRange(location: 0, length: count(str.utf16))) {
|
||||
let match = x as! NSTextCheckingResult
|
||||
// match.range gives the range of the whole match
|
||||
// match.rangeAtIndex(i) gives the range of the i'th capture group (starting from 1)
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import Foundation
|
||||
|
||||
let orig = "I am the original string"
|
||||
if let regex = NSRegularExpression(pattern: "original", options: nil, error: nil) {
|
||||
let result = regex.stringByReplacingMatchesInString(orig, options: nil, range: NSRange(location: 0, length: count(orig.utf16)), withTemplate: "modified")
|
||||
println(result)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue