Last active
July 26, 2017 12:04
-
-
Save loucimj/fcbf40ba9e676150949dde50e5f53a68 to your computer and use it in GitHub Desktop.
search for mention with dots in the middle
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
content//: Playground - noun: a place where people can play | |
import UIKit | |
import Foundation | |
var str = "Hello, @playground.something more" | |
//(?<=\\s|^|\\b)(?:[-'.%$#&/]\\b|\\b[-'.%$#&/]|[A-Za-z0-9]|\\([A-Za-z0-9]+\\))+(?=\\s|$|\\b) | |
let range = NSMakeRange(0, str.characters.count) | |
var regex = try! NSRegularExpression(pattern: "@(?<=\\s|^|\\b)(?:[-'.%$#&/]\\b|\\b[-'.%$#&/]|[A-Za-z0-9]|\\([A-Za-z0-9]+\\))+(?=\\s|$|\\b)", options: .caseInsensitive) | |
regex.stringByReplacingMatches(in: str, options: [], range: range, withTemplate: "Found ya!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment