 //
 
 import Foundation
+#if os(iOS)
+import UIKit
+#elseif os(OSX)
+import Cocoa
+#endif
 
+//The support support class that keeps a track of the patterns while processing
 class Pattern {
-    var matched:((String,String,Int) -> (text: String,offset: Int))?
+    var matched:((String,String,Int) -> (text: String,attrs: [NSObject : AnyObject]?))?
     var start = 0
-    var end = -1
+    var length = -1
+    var attrs: [NSObject : AnyObject]?
     var text: String
     var recursive: Bool
     var current: Character
     var mustFullfill = true
     var index = 0
     var rewindIndex = 0
-    init(_ text: String, _ start: Int, _ recursive: Bool, _ matched: ((String,String,Int) -> (String,Int))?) {
+    init(_ text: String, _ start: Int, _ recursive: Bool, _ matched: ((String,String,Int) -> (String,[NSObject : AnyObject]?))?) {
         self.mustFullfill = true
         self.recursive = recursive
         self.start = start

            }
            index++
        }
        return text
    }
}

class Matcher {
    var src: String
    var recursive: Bool
    var matched:((String,String,Int) -> (String,[NSObject : AnyObject]?))?
    init(src: String,recursive: Bool ,matched:((String,String,Int) -> (String,[NSObject : AnyObject]?))?) {
        self.src = src
        self.matched = matched
        self.recursive = recursive
