             var regexMatches = [regmatch_t](count: maxMatches, repeatedValue: regmatch_t())
             let result = regexec(&preg, string, regexMatches.count, &regexMatches, options.rawValue)
 
-            if result == REG_NOMATCH {
+            if result == 1 {
                 break
             }
 

        var regexMatches = [regmatch_t](count: 1, repeatedValue: regmatch_t())
        let result = regexec(&preg, string, regexMatches.count, &regexMatches, options.rawValue)

        if result == REG_NOMATCH {
            return false
        }

        return true
    }

    public func groups(var string: String, options: MatchOptions = []) -> [String] {
        let maxMatches = 10
        var groups = [String]()


            let templateArray = Array<UInt8>(template.utf8)
            replacedStringArray.replaceRange(start ..<  end, with: templateArray)

            guard let _replacedString = String(data: replacedStringArray) else {
                break
            }

            var replacedString = _replacedString

            let templateDelta = template.utf8.count - (end - start)
            let templateDeltaIndex = replacedString.utf8.startIndex.advancedBy(Int(end + templateDelta))
