 }
 
 extension StreamReader : SequenceType {
-    func generate() -> GeneratorOf<String> {
-        return GeneratorOf<String> {
+    func generate() -> AnyGenerator<String> {
+        return anyGenerator{
             return self.nextLine()
         }
     }
 }
 
 extension String {
-    func substringsMatchingPattern(let pattern: String, let options: NSRegularExpressionOptions, let matchGroup: Int, error: NSErrorPointer) -> [String] {
-        let range = NSMakeRange(0, count(self))
-        let regex = NSRegularExpression(pattern: pattern, options: options, error: error)
-        let matches = regex?.matchesInString(self, options: nil, range: range)
+    func substringsMatchingPattern(let pattern: String, let options: NSRegularExpressionOptions, let matchGroup: Int) throws -> [String] {
+        let range = NSMakeRange(0, (self as NSString).length)
+        let regex = try NSRegularExpression(pattern: pattern, options: options)
+        let matches = regex.matchesInString(self, options: [], range: range)
         
         var output: [String] = []
 
-        for match in matches as! [NSTextCheckingResult] {
+        for match in matches  {
             let matchRange = match.rangeAtIndex(matchGroup)
             let matchString = (self as NSString).substringWithRange(matchRange)
             output.append(matchString as String)

                
            }
            
            println(outputText)
            
            previousLineState = lineState
            

        
        // Handle the closing tags
        if lineState == .SwiftCode && previousLineState == .SwiftCode {
            print(MarkdownCodeEndDelimiter)
        }
    }
    
