 
             :returns: Subscript for the capture group.
         */
-        public subscript(index: Int) -> String {
-            return subject[ranges[index]]
+        public subscript(index: Int) -> String? {
+            if let range = ranges[index] {
+                return subject[range]
+            } else {
+                return nil
+            }
         }
     }
 

            // Get the capture groups
            for matchRangeIdx in 0..<matchResult.numberOfRanges {
                let matchRange = matchResult.rangeAtIndex(matchRangeIdx)
                let beginIndex = advance(subject.startIndex, matchRange.location)
                let endIndex = advance(beginIndex, matchRange.length)

                ranges.append(beginIndex..<endIndex)
            }

            self.ranges = ranges

        return search(subject) != nil
    }
}
