             let range = NSRange(location: 0, length: self.length)
             
             let matches = regularExpression.matchesInString(self.string, options: NSMatchingOptions(rawValue: 0), range: range)
-            for match in matches {
-                let range = (tokenized ? match.rangeAtIndex(match.numberOfRanges-1) : match.range)
-                
-                let attributes = ZenCopy.manager.attributesForStyle(style)
-                if replace {
-                    self.setAttributes(attributes, range: range)
-                } else if let attributes = attributes {
-                    self.addAttributes(attributes, range: range)
-                }
-            }
             
-            return matches
+            return self.style(style, matches: matches, tokenized: tokenized, replace: replace)
         } catch _ {
             
         }
         return nil
     }
-}
+}
        return self.style(style, regex: regex, tokenized: tokenized, replace: false)
    }
    
    // Set (replace) style
    public func setStyle(named styleName: String, regex: String, tokenized: Bool = true) -> [NSTextCheckingResult]? {
        let style = Style()
        for styleName in ZenCopy.manager.styleNamesFromStyleString(styleName) {

import Foundation

public extension NSMutableAttributedString {
    // Add style
    public func addStyle(named styleName: String, regex: String) -> [NSTextCheckingResult]? {
