Created
March 22, 2021 19:17
-
-
Save ayosec/ac8e0c55c3a3f3c352ab493a53a1ded1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let data = "aaa 11-22 bbb 33-44 ccc" | |
let regex = try! NSRegularExpression(pattern: #"\d+-\d+"#) | |
let range = NSRange(data.startIndex..., in: data) | |
regex.enumerateMatches(in: data, options: [], range: range) { (match, _, _) in | |
print(data.substring(with: match!.range)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment