             result.range.location
         }
         return nil
+    }
+    
+    public struct Match {
+        let components: [(String, Range<String.Index>)]
+        
+        func subStrings() -> [String] {
+            return components.map {
+                $0.0
+            }
+        }
+        
+        func ranges() -> [Range<String.Index>] {
+            return components.map {
+                $0.1
+            }
+        }
     }
 }
 

}

extension String {
    public func match(regex: Regex) -> [Regex.Match] {
        return regex.matchWithPattern(self)
    }
    

import Foundation

public struct Regex {
    
    private var regexPattern: NSRegularExpression
    
