Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. let hashTagPattern = "(?<=^|\\s)#([\\p{Alphabetic}_]\\w*)(?:\\s|$)"
  2.  
  3. let hashtagRegExp = try! NSRegularExpression(pattern: hashTagPattern,
  4. options: .CaseInsensitive)
  5.  
  6. let string = "#qAS ###Привет_2016 #Привет_2016 Hello #1qa #a__1 #__a__1 #qweqваваwe#qweqwe #DDSFdsf"
  7. let nsString = string as NSString
  8.  
  9. hashtagRegExp.enumerateMatchesInString(string,
  10. options: NSMatchingOptions(rawValue: 0),
  11. range: NSRange(location: 0, length: nsString.length)) {
  12. result, _, _ in
  13. if let result = result {
  14. print("'\(nsString.substringWithRange(result.rangeAtIndex(1)))'")
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement