Skip to content

Instantly share code, notes, and snippets.

@maxhis
maxhis / Swift extension to NSMutableAttributedString (highlight and replace)
Last active February 23, 2016 08:24 — forked from sketchytech/Swift extension to NSMutableAttributedString (highlight and replace)
Swift extension to NSMutableAttributedString adding methods for highlighting and replacing substrings (swift 2.0 supportted)
extension NSMutableAttributedString {
func highlightStrings(stringToHighlight:String, usingRegex:Bool = false) {
var useRegex:NSRegularExpressionOptions?
if !usingRegex {
useRegex = NSRegularExpressionOptions.IgnoreMetacharacters
}