Tusker/MyPlayground.playground/Contents.swift

15 lines
516 B
Swift

import UIKit
let regex = try! NSRegularExpression(pattern: ":[a-zA-Z0-9_]+:", options: [])
func stripCustomEmoji(from string: String) -> String {
let range = NSRange(location: 0, length: string.utf16.count)
return regex.stringByReplacingMatches(in: string, options: [], range: range, withTemplate: "")
}
let result = stripCustomEmoji(from: ":sparkles_nb: 🦑 :dizzy_trans:")
stripCustomEmoji(from: ":dizzy_trans:")
stripCustomEmoji(from: " 🦑 :dizzy_trans:")
stripCustomEmoji(from: " :dizzy_trans:")