packages feed

pcre-light-0.1: tests/testdata/regex1.tests


testRegex "^(a){1,}" []
    ["bcd",
     "abc",
     "aab",
     "aaa",
     "aaaaaaaa    "]
    [Nothing,
     Just [" 0: a"],
     Just [" 1: a"],
     Just [" 0: aa"],
     Just [" 1: a"],
     Just [" 0: aaa"],
     Just [" 1: a"],
     Just [" 0: aaaaaaaa"],
     Just [" 1: a"]]
,











testRegex ".*$" [ERROR]
    ["borfle\\nbib.gif\\nno\\n"]
    [Just [" 0: borfle\\x0abib.gif\\x0ano\\x0a"]]
,


testRegex ".*$" [ERROR]
    ["borfle\\nbib.gif\\nno\\n",
     "",
     "/(.*X|^B)/",
     "abcde\\n1234Xyz",
     "BarFoo ",
     "*** Failers",
     "abcde\\nBar  "]
    [Just [" 0: borfle\\x0abib.gif\\x0ano\\x0a"],
     Just ["/(.*X|^B)/"],
     Just [" 0: 1234X"],
     Just [" 1: 1234X"],
     Just [" 0: B"],
     Just [" 1: B"],
     Nothing,
     Nothing]
,


testRegex "(.*X|^B)" [ERROR]
    ["abcde\\n1234Xyz",
     "BarFoo ",
     "abcde\\nBar  "]
    [Just [" 0: 1234X"],
     Just [" 1: 1234X"],
     Just [" 0: B"],
     Just [" 1: B"],
     Just [" 0: B"],
     Just [" 1: B"]]
,


testRegex "(.*X|^B)" [ERROR]
    ["abcde\\n1234Xyz",
     "BarFoo ",
     "*** Failers",
     "abcde\\nBar  "]
    [Just [" 0: abcde\\x0a1234X"],
     Just [" 1: abcde\\x0a1234X"],
     Just [" 0: B"],
     Just [" 1: B"],
     Nothing,
     Nothing]
,


testRegex "(.*X|^B)" [ERROR]
    ["abcde\\n1234Xyz",
     "BarFoo ",
     "abcde\\nBar  "]
    [Just [" 0: abcde\\x0a1234X"],
     Just [" 1: abcde\\x0a1234X"],
     Just [" 0: B"],
     Just [" 1: B"],
     Just [" 0: B"],
     Just [" 1: B"]]
,


testRegex "(?s)(.*X|^B)" []
    ["abcde\\n1234Xyz",
     "BarFoo ",
     "*** Failers ",
     "abcde\\nBar  "]
    [Just [" 0: abcde\\x0a1234X"],
     Just [" 1: abcde\\x0a1234X"],
     Just [" 0: B"],
     Just [" 1: B"],
     Nothing,
     Nothing]
,


testRegex "(?s:.*X|^B)" []
    ["abcde\\n1234Xyz",
     "BarFoo ",
     "*** Failers ",
     "abcde\\nBar  "]
    [Just [" 0: abcde\\x0a1234X"],
     Just [" 0: B"],
     Nothing,
     Nothing]
,


testRegex "^.*B" []
    ["**** Failers",
     "abc\\nB",
     "",
     "/(?s)^.*B/",
     "abc\\nB"]
    [Nothing,
     Nothing,
     Just ["/(?s)^.*B/"],
     Just [" 0: abc\\x0aB"]]
,


testRegex "(?m)^.*B" []
    ["abc\\nB",
     "",
     "/(?ms)^.*B/",
     "abc\\nB"]
    [Just [" 0: B"],
     Just ["/(?ms)^.*B/"],
     Just [" 0: abc\\x0aB"]]
,




testRegex "^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]" []
    ["123456654321",
     "",
     "/^\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d/",
     "123456654321 "]
    [Just [" 0: 123456654321"],
     Just ["/^\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d/"],
     Just [" 0: 123456654321"]]
,


testRegex "^[\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d][\\d]" []
    ["123456654321",
     "",
     "/^[abc]{12}/",
     "abcabcabcabc",
     "",
     "/^[a-c]{12}/",
     "abcabcabcabc",
     "",
     "/^(a|b|c){12}/",
     "abcabcabcabc "]
    [Just [" 0: 123456654321"],
     Just ["/^[abc]{12}/"],
     Just [" 0: abcabcabcabc"],
     Just ["/^[a-c]{12}/"],
     Just [" 0: abcabcabcabc"],
     Just ["/^(a|b|c){12}/"],
     Just [" 0: abcabcabcabc"],
     Just [" 1: c"]]
,





testRegex "" [ERROR]
    ["abc"]
    [Just [" 0: "],
     Just [" 0: "],
     Just [" 0: "],
     Just [" 0: "]]
,


testRegex "<tr([\\w\\W\\s\\d][^<>]{0,})><TD([\\w\\W\\s\\d][^<>]{0,})>([\\d]{0,}\\.)(.*)((<BR>([\\w\\W\\s\\d][^<>]{0,})|[\\s]{0,}))<\\/a><\\/TD><TD([\\w\\W\\s\\d][^<>]{0,})>([\\w\\W\\s\\d][^<>]{0,})<\\/TD><TD([\\w\\W\\s\\d][^<>]{0,})>([\\w\\W\\s\\d][^<>]{0,})<\\/TD><\\/TR>" [ERROR]
    ["<TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>"]
    [Just [" 0: <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>"],
     Just [" 1:  BGCOLOR='#DBE9E9'"],
     Just [" 2:  align=left valign=top"],
     Just [" 3: 43."],
     Just [" 4: <a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)"],
     Just [" 5: "],
     Just [" 6: "],
     Just [" 7: <unset>"],
     Just [" 8:  align=left valign=top"],
     Just [" 9: Lega lstaff.com"],
     Just ["10:  align=left valign=top"],
     Just ["11: CA - Statewide"]]
,


testRegex "a[^a]b" []
    ["acb",
     "a\\nb",
     "",
     "/a.b/",
     "acb",
     "*** Failers ",
     "a\\nb   ",
     "",
     "/a[^a]b/s",
     "acb",
     "a\\nb  ",
     "",
     "/a.b/s",
     "acb",
     "a\\nb  "]
    [Just [" 0: acb"],
     Just [" 0: a\\x0ab"],
     Just ["/a.b/"],
     Just [" 0: acb"],
     Nothing,
     Nothing,
     Just ["/a[^a]b/s"],
     Just [" 0: acb"],
     Just [" 0: a\\x0ab"],
     Just ["/a.b/s"],
     Just [" 0: acb"],
     Just [" 0: a\\x0ab"]]
,



testRegex "^(b+|a){1,2}?c" []
    ["bac",
     "bbac",
     "bbbac",
     "bbbbac",
     "bbbbbac ",
     "",
     "/(?!\\A)x/m",
     "x\\nb\\n",
     "a\\bx\\n  ",
     "",
     "/\\x0{ab}/",
     "\\0{ab} "]
    [Just [" 0: bac"],
     Just [" 1: a"],
     Just [" 0: bbac"],
     Just [" 1: a"],
     Just [" 0: bbbac"],
     Just [" 1: a"],
     Just [" 0: bbbbac"],
     Just [" 1: a"],
     Just [" 0: bbbbbac"],
     Just [" 1: a"],
     Just ["/(?!\\A)x/m"],
     Nothing,
     Just [" 0: x"],
     Just ["/\\x0{ab}/"],
     Just [" 0: \\x00{ab}"]]
,




testRegex "(AB)*\\1" []
    ["ABABAB",
     "",
     "/(?<!bar)foo/",
     "foo",
     "catfood",
     "arfootle",
     "rfoosh",
     "*** Failers",
     "barfoo",
     "towbarfoo"]
    [Just [" 0: ABABAB"],
     Just [" 1: AB"],
     Just ["/(?<!bar)foo/"],
     Just [" 0: foo"],
     Just [" 0: foo"],
     Just [" 0: foo"],
     Just [" 0: foo"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "\\w{3}(?<!bar)foo" []
    ["catfood",
     "*** Failers",
     "foo",
     "barfoo",
     "towbarfoo"]
    [Just [" 0: catfoo"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?<=(foo)a)bar" []
    ["fooabar",
     "*** Failers",
     "bar",
     "foobbar",
     "",
     "/\\Aabc\\z/m",
     "abc",
     "*** Failers",
     "abc\\n   ",
     "qqq\\nabc",
     "abc\\nzzz",
     "qqq\\nabc\\nzzz"]
    [Just [" 0: bar"],
     Just [" 1: foo"],
     Nothing,
     Nothing,
     Nothing,
     Just ["/\\Aabc\\z/m"],
     Just [" 0: abc"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?>.*/)foo" [ERROR]
    ["/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/"]
    [Nothing]
,


testRegex "(?>.*/)foo" [ERROR]
    ["/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo"]
    [Just [" 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo"]]
,


testRegex "(?>(\\.\\d\\d[1-9]?))\\d+" []
    ["1.230003938",
     "1.875000282",
     "*** Failers ",
     "1.235 "]
    [Just [" 0: .230003938"],
     Just [" 1: .23"],
     Just [" 0: .875000282"],
     Just [" 1: .875"],
     Nothing,
     Nothing]
,


testRegex "^((?>\\w+)|(?>\\s+))*$" []
    ["now is the time for all good men to come to the aid of the party",
     "*** Failers",
     "this is not a line with only words and spaces!",
     "",
     "/(\\d+)(\\w)/",
     "12345a",
     "12345+ "]
    [Just [" 0: now is the time for all good men to come to the aid of the party"],
     Just [" 1: party"],
     Nothing,
     Nothing,
     Just ["/(\\d+)(\\w)/"],
     Just [" 0: 12345a"],
     Just [" 1: 12345"],
     Just [" 2: a"],
     Just [" 0: 12345"],
     Just [" 1: 1234"],
     Just [" 2: 5"]]
,


testRegex "((?>\\d+))(\\w)" []
    ["12345a",
     "*** Failers",
     "12345+ "]
    [Just [" 0: 12345a"],
     Just [" 1: 12345"],
     Just [" 2: a"],
     Nothing,
     Nothing]
,


testRegex "(?>a+)b" []
    ["aaab"]
    [Just [" 0: aaab"]]
,


testRegex "((?>a+)b)" []
    ["aaab"]
    [Just [" 0: aaab"],
     Just [" 1: aaab"]]
,


testRegex "(?>(a+))b" []
    ["aaab"]
    [Just [" 0: aaab"],
     Just [" 1: aaa"]]
,


testRegex "(?>b)+" []
    ["aaabbbccc"]
    [Just [" 0: bbb"]]
,


testRegex "(?>a+|b+|c+)*c" []
    ["aaabbbbccccd"]
    [Just [" 0: aaabbbbc"]]
,


testRegex "((?>[^()]+)|\\([^()]*\\))+" []
    ["((abc(ade)ufh()()x",
     "",
     "/\\(((?>[^()]+)|\\([^()]+\\))+\\)/ ",
     "(abc)",
     "(abc(def)xyz)",
     "*** Failers",
     "((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   "]
    [Just [" 0: abc(ade)ufh()()x"],
     Just [" 1: x"],
     Just ["/\\(((?>[^()]+)|\\([^()]+\\))+\\)/ "],
     Just [" 0: (abc)"],
     Just [" 1: abc"],
     Just [" 0: (abc(def)xyz)"],
     Just [" 1: xyz"],
     Nothing,
     Nothing]
,


testRegex "a(?-i)b" [caseless]
    ["ab",
     "Ab",
     "*** Failers ",
     "aB",
     "AB",
     "",
     "/(a (?x)b c)d e/",
     "a bcd e",
     "*** Failers",
     "a b cd e",
     "abcd e   ",
     "a bcde ",
     "",
     "/(a b(?x)c d (?-x)e f)/",
     "a bcde f",
     "*** Failers",
     "abcdef  "]
    [Just [" 0: ab"],
     Just [" 0: Ab"],
     Nothing,
     Nothing,
     Nothing,
     Just ["/(a (?x)b c)d e/"],
     Just [" 0: a bcd e"],
     Just [" 1: a bc"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Just ["/(a b(?x)c d (?-x)e f)/"],
     Just [" 0: a bcde f"],
     Just [" 1: a bcde f"],
     Nothing,
     Nothing]
,


testRegex "(a(?i)b)c" []
    ["abc",
     "aBc",
     "*** Failers",
     "abC",
     "aBC  ",
     "Abc",
     "ABc",
     "ABC",
     "AbC",
     "",
     "/a(?i:b)c/",
     "abc",
     "aBc",
     "*** Failers ",
     "ABC",
     "abC",
     "aBC",
     "",
     "/a(?i:b)*c/",
     "aBc",
     "aBBc",
     "*** Failers ",
     "aBC",
     "aBBC",
     "",
     "/a(?=b(?i)c)\\w\\wd/",
     "abcd",
     "abCd",
     "*** Failers",
     "aBCd",
     "abcD     ",
     "",
     "/(?s-i:more.*than).*million/i",
     "more than million",
     "more than MILLION",
     "more \\n than Million ",
     "*** Failers",
     "MORE THAN MILLION    ",
     "more \\n than \\n million "]
    [Just [" 0: abc"],
     Just [" 1: ab"],
     Just [" 0: aBc"],
     Just [" 1: aB"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Just ["/a(?i:b)c/"],
     Just [" 0: abc"],
     Just [" 0: aBc"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Just ["/a(?i:b)*c/"],
     Just [" 0: aBc"],
     Just [" 0: aBBc"],
     Nothing,
     Nothing,
     Nothing,
     Just ["/a(?=b(?i)c)\\w\\wd/"],
     Just [" 0: abcd"],
     Just [" 0: abCd"],
     Nothing,
     Nothing,
     Nothing,
     Just ["/(?s-i:more.*than).*million/i"],
     Just [" 0: more than million"],
     Just [" 0: more than MILLION"],
     Just [" 0: more \\x0a than Million"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?:(?s-i)more.*than).*million" [caseless]
    ["more than million",
     "more than MILLION",
     "more \\n than Million ",
     "*** Failers",
     "MORE THAN MILLION    ",
     "more \\n than \\n million ",
     "",
     "/(?>a(?i)b+)+c/ ",
     "abc",
     "aBbc",
     "aBBc ",
     "*** Failers",
     "Abc",
     "abAb    ",
     "abbC ",
     "",
     "/(?=a(?i)b)\\w\\wc/",
     "abc",
     "aBc",
     "*** Failers",
     "Ab ",
     "abC",
     "aBC     ",
     "",
     "/(?<=a(?i)b)(\\w\\w)c/",
     "abxxc",
     "aBxxc",
     "*** Failers",
     "Abxxc",
     "ABxxc",
     "abxxC      "]
    [Just [" 0: more than million"],
     Just [" 0: more than MILLION"],
     Just [" 0: more \\x0a than Million"],
     Nothing,
     Nothing,
     Nothing,
     Just ["/(?>a(?i)b+)+c/ "],
     Just [" 0: abc"],
     Just [" 0: aBbc"],
     Just [" 0: aBBc"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Just ["/(?=a(?i)b)\\w\\wc/"],
     Just [" 0: abc"],
     Just [" 0: aBc"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Just ["/(?<=a(?i)b)(\\w\\w)c/"],
     Just [" 0: xxc"],
     Just [" 1: xx"],
     Just [" 0: xxc"],
     Just [" 1: xx"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?:(a)|b)(?(1)A|B)" []
    ["aA",
     "bB",
     "*** Failers",
     "aB",
     "bA    "]
    [Just [" 0: aA"],
     Just [" 1: a"],
     Just [" 0: bB"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^(a)?(?(1)a|b)+$" []
    ["aa",
     "b",
     "bb  ",
     "*** Failers",
     "ab   "]
    [Just [" 0: aa"],
     Just [" 1: a"],
     Just [" 0: b"],
     Just [" 0: bb"],
     Nothing,
     Nothing]
,


testRegex "^(?(?=abc)\\w{3}:|\\d\\d)$" []
    ["abc:",
     "12",
     "*** Failers",
     "123",
     "xyz    "]
    [Just [" 0: abc:"],
     Just [" 0: 12"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^(?(?!abc)\\d\\d|\\w{3}:)$" []
    ["abc:",
     "12",
     "*** Failers",
     "123",
     "xyz    ",
     "",
     "/(?(?<=foo)bar|cat)/",
     "foobar",
     "cat",
     "fcat",
     "focat   ",
     "*** Failers",
     "foocat  "]
    [Just [" 0: abc:"],
     Just [" 0: 12"],
     Nothing,
     Nothing,
     Nothing,
     Just ["/(?(?<=foo)bar|cat)/"],
     Just [" 0: bar"],
     Just [" 0: cat"],
     Just [" 0: cat"],
     Just [" 0: cat"],
     Nothing,
     Nothing]
,


testRegex "(?(?<!foo)cat|bar)" []
    ["foobar",
     "cat",
     "fcat",
     "focat   ",
     "*** Failers",
     "foocat  "]
    [Just [" 0: bar"],
     Just [" 0: cat"],
     Just [" 0: cat"],
     Just [" 0: cat"],
     Nothing,
     Nothing]
,


testRegex "( \\( )? [^()]+ (?(1) \\) |) " [ERROR]
    ["abcd",
     "(abcd)",
     "the quick (abcd) fox",
     "(abcd   "]
    [Just [" 0: abcd"],
     Just [" 0: (abcd)"],
     Just [" 1: ("],
     Just [" 0: the quick "],
     Just [" 0: abcd"]]
,


testRegex "( \\( )? [^()]+ (?(1) \\) ) " [ERROR]
    ["abcd",
     "(abcd)",
     "the quick (abcd) fox",
     "(abcd   "]
    [Just [" 0: abcd"],
     Just [" 0: (abcd)"],
     Just [" 1: ("],
     Just [" 0: the quick "],
     Just [" 0: abcd"]]
,


testRegex "^(?(2)a|(1)(2))+$" []
    ["12",
     "12a",
     "12aa",
     "*** Failers",
     "1234    "]
    [Just [" 0: 12"],
     Just [" 1: 1"],
     Just [" 2: 2"],
     Just [" 0: 12a"],
     Just [" 1: 1"],
     Just [" 2: 2"],
     Just [" 0: 12aa"],
     Just [" 1: 1"],
     Just [" 2: 2"],
     Nothing,
     Nothing]
,


testRegex "((?i)blah)\\s+\\1" []
    ["blah blah",
     "BLAH BLAH",
     "Blah Blah",
     "blaH blaH",
     "*** Failers",
     "blah BLAH",
     "Blah blah      ",
     "blaH blah "]
    [Just [" 0: blah blah"],
     Just [" 1: blah"],
     Just [" 0: BLAH BLAH"],
     Just [" 1: BLAH"],
     Just [" 0: Blah Blah"],
     Just [" 1: Blah"],
     Just [" 0: blaH blaH"],
     Just [" 1: blaH"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "((?i)blah)\\s+(?i:\\1)" []
    ["blah blah",
     "BLAH BLAH",
     "Blah Blah",
     "blaH blaH",
     "blah BLAH",
     "Blah blah      ",
     "blaH blah "]
    [Just [" 0: blah blah"],
     Just [" 1: blah"],
     Just [" 0: BLAH BLAH"],
     Just [" 1: BLAH"],
     Just [" 0: Blah Blah"],
     Just [" 1: Blah"],
     Just [" 0: blaH blaH"],
     Just [" 1: blaH"],
     Just [" 0: blah BLAH"],
     Just [" 1: blah"],
     Just [" 0: Blah blah"],
     Just [" 1: Blah"],
     Just [" 0: blaH blah"],
     Just [" 1: blaH"]]
,


testRegex "(?>a*)*" []
    ["a",
     "aa",
     "aaaa",
     "",
     "/(abc|)+/",
     "abc",
     "abcabc",
     "abcabcabc",
     "xyz      "]
    [Just [" 0: a"],
     Just [" 0: aa"],
     Just [" 0: aaaa"],
     Just ["/(abc|)+/"],
     Just [" 0: abc"],
     Just [" 1: "],
     Just [" 0: abcabc"],
     Just [" 1: "],
     Just [" 0: abcabcabc"],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "]]
,


testRegex "([a]*)*" []
    ["a",
     "aaaaa ",
     "",
     "/([ab]*)*/",
     "a",
     "b",
     "ababab",
     "aaaabcde",
     "bbbb    ",
     "",
     "/([^a]*)*/",
     "b",
     "bbbb",
     "aaa   ",
     "",
     "/([^ab]*)*/",
     "cccc",
     "abab  ",
     "",
     "/([a]*?)*/",
     "a",
     "aaaa ",
     "",
     "/([ab]*?)*/",
     "a",
     "b",
     "abab",
     "baba   ",
     "",
     "/([^a]*?)*/",
     "b",
     "bbbb",
     "aaa   ",
     "",
     "/([^ab]*?)*/",
     "c",
     "cccc",
     "baba   ",
     "",
     "/(?>a*)*/",
     "a",
     "aaabcde ",
     "",
     "/((?>a*))*/",
     "aaaaa",
     "aabbaa ",
     "",
     "/((?>a*?))*/",
     "aaaaa",
     "aabbaa "]
    [Just [" 0: a"],
     Just [" 1: "],
     Just [" 0: aaaaa"],
     Just [" 1: "],
     Just ["/([ab]*)*/"],
     Just [" 0: a"],
     Just [" 1: "],
     Just [" 0: b"],
     Just [" 1: "],
     Just [" 0: ababab"],
     Just [" 1: "],
     Just [" 0: aaaab"],
     Just [" 1: "],
     Just [" 0: bbbb"],
     Just [" 1: "],
     Just ["/([^a]*)*/"],
     Just [" 0: b"],
     Just [" 1: "],
     Just [" 0: bbbb"],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just ["/([^ab]*)*/"],
     Just [" 0: cccc"],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just ["/([a]*?)*/"],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just ["/([ab]*?)*/"],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just ["/([^a]*?)*/"],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just ["/([^ab]*?)*/"],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "],
     Just ["/(?>a*)*/"],
     Just [" 0: a"],
     Just [" 0: aaa"],
     Just ["/((?>a*))*/"],
     Just [" 0: aaaaa"],
     Just [" 1: "],
     Just [" 0: aa"],
     Just [" 1: "],
     Just ["/((?>a*?))*/"],
     Just [" 0: "],
     Just [" 1: "],
     Just [" 0: "],
     Just [" 1: "]]
,


testRegex "(?(?=[^a-z]+[a-z])  \\d{2}-[a-z]{3}-\\d{2}  |  \\d{2}-\\d{2}-\\d{2} ) " [ERROR]
    ["12-sep-98",
     "12-09-98",
     "*** Failers",
     "sep-12-98",
     "",
     "/(?<=(foo))bar\\1/",
     "foobarfoo",
     "foobarfootling ",
     "*** Failers",
     "foobar",
     "barfoo   "]
    [Just [" 0: 12-sep-98"],
     Just [" 0: 12-09-98"],
     Nothing,
     Nothing,
     Just ["/(?<=(foo))bar\\1/"],
     Just [" 0: barfoo"],
     Just [" 1: foo"],
     Just [" 0: barfoo"],
     Just [" 1: foo"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?i:saturday|sunday)" []
    ["saturday",
     "sunday",
     "Saturday",
     "Sunday",
     "SATURDAY",
     "SUNDAY",
     "SunDay",
     "",
     "/(a(?i)bc|BB)x/",
     "abcx",
     "aBCx",
     "bbx",
     "BBx",
     "*** Failers",
     "abcX",
     "aBCX",
     "bbX",
     "BBX               "]
    [Just [" 0: saturday"],
     Just [" 0: sunday"],
     Just [" 0: Saturday"],
     Just [" 0: Sunday"],
     Just [" 0: SATURDAY"],
     Just [" 0: SUNDAY"],
     Just [" 0: SunDay"],
     Just ["/(a(?i)bc|BB)x/"],
     Just [" 0: abcx"],
     Just [" 1: abc"],
     Just [" 0: aBCx"],
     Just [" 1: aBC"],
     Just [" 0: bbx"],
     Just [" 1: bb"],
     Just [" 0: BBx"],
     Just [" 1: BB"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^([ab](?i)[cd]|[ef])" []
    ["ac",
     "aC",
     "bD",
     "elephant",
     "Europe ",
     "frog",
     "France",
     "*** Failers",
     "Africa     "]
    [Just [" 0: ac"],
     Just [" 1: ac"],
     Just [" 0: aC"],
     Just [" 1: aC"],
     Just [" 0: bD"],
     Just [" 1: bD"],
     Just [" 0: e"],
     Just [" 1: e"],
     Just [" 0: E"],
     Just [" 1: E"],
     Just [" 0: f"],
     Just [" 1: f"],
     Just [" 0: F"],
     Just [" 1: F"],
     Nothing,
     Nothing]
,


testRegex "^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)" []
    ["ab",
     "aBd",
     "xy",
     "xY",
     "zebra",
     "Zambesi",
     "*** Failers",
     "aCD  ",
     "XY  "]
    [Just [" 0: ab"],
     Just [" 1: ab"],
     Just [" 0: aBd"],
     Just [" 1: aBd"],
     Just [" 0: xy"],
     Just [" 1: xy"],
     Just [" 0: xY"],
     Just [" 1: xY"],
     Just [" 0: z"],
     Just [" 1: z"],
     Just [" 0: Z"],
     Just [" 1: Z"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?<=foo\\n)^bar" [ERROR]
    ["foo\\nbar",
     "*** Failers",
     "bar",
     "baz\\nbar   "]
    [Just [" 0: bar"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?<=(?<!foo)bar)baz" []
    ["barbaz",
     "barbarbaz ",
     "koobarbaz ",
     "*** Failers",
     "baz",
     "foobarbaz "]
    [Just [" 0: baz"],
     Just [" 0: baz"],
     Just [" 0: baz"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "The case of aaaaaa is missed out below because I think Perl 5.005_02 gets" []
    ["/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/",
     "/where it does set $1 to aa when matching aaaaaa./"]
    [Just ["/it wrong; it sets $1 to aaa rather than aa. Compare the following test,/"],
     Nothing,
     Just ["/where it does set $1 to aa when matching aaaaaa./"],
     Nothing]
,


testRegex "^(a\\1?){4}$" []
    ["a",
     "aa",
     "aaa",
     "aaaa",
     "aaaaa",
     "aaaaaaa",
     "aaaaaaaa",
     "aaaaaaaaa",
     "aaaaaaaaaa",
     "aaaaaaaaaaa",
     "aaaaaaaaaaaa",
     "aaaaaaaaaaaaa",
     "aaaaaaaaaaaaaa",
     "aaaaaaaaaaaaaaa",
     "aaaaaaaaaaaaaaaa               "]
    [Nothing,
     Nothing,
     Nothing,
     Just [" 0: aaaa"],
     Just [" 1: a"],
     Just [" 0: aaaaa"],
     Just [" 1: a"],
     Just [" 0: aaaaaaa"],
     Just [" 1: a"],
     Nothing,
     Nothing,
     Just [" 0: aaaaaaaaaa"],
     Just [" 1: aaaa"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^(a\\1?)(a\\1?)(a\\2?)(a\\3?)$" []
    ["a",
     "aa",
     "aaa",
     "aaaa",
     "aaaaa",
     "aaaaaa",
     "aaaaaaa",
     "aaaaaaaa",
     "aaaaaaaaa",
     "aaaaaaaaaa",
     "aaaaaaaaaaa",
     "aaaaaaaaaaaa",
     "aaaaaaaaaaaaa",
     "aaaaaaaaaaaaaa",
     "aaaaaaaaaaaaaaa",
     "aaaaaaaaaaaaaaaa               "]
    [Nothing,
     Nothing,
     Nothing,
     Just [" 0: aaaa"],
     Just [" 1: a"],
     Just [" 2: a"],
     Just [" 3: a"],
     Just [" 4: a"],
     Just [" 0: aaaaa"],
     Just [" 1: a"],
     Just [" 2: aa"],
     Just [" 3: a"],
     Just [" 4: a"],
     Just [" 0: aaaaaa"],
     Just [" 1: a"],
     Just [" 2: aa"],
     Just [" 3: a"],
     Just [" 4: aa"],
     Just [" 0: aaaaaaa"],
     Just [" 1: a"],
     Just [" 2: aa"],
     Just [" 3: aaa"],
     Just [" 4: a"],
     Nothing,
     Nothing,
     Just [" 0: aaaaaaaaaa"],
     Just [" 1: a"],
     Just [" 2: aa"],
     Just [" 3: aaa"],
     Just [" 4: aaaa"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "The following tests are taken from the Perl 5.005 test suite; some of them" []
    ["/are compatible with 5.004, but I'd rather not have to sort them out./"]
    [Just ["/are compatible with 5.004, but I'd rather not have to sort them out./"],
     Nothing]
,


testRegex "abc" []
    ["abc",
     "xabcy",
     "ababc",
     "*** Failers",
     "xbc",
     "axc",
     "abx"]
    [Just [" 0: abc"],
     Just [" 0: abc"],
     Just [" 0: abc"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "ab*c" []
    ["abc"]
    [Just [" 0: abc"]]
,


testRegex "ab*bc" []
    ["abc",
     "abbc",
     "abbbbc"]
    [Just [" 0: abc"],
     Just [" 0: abbc"],
     Just [" 0: abbbbc"]]
,


testRegex ".{1}" []
    ["abbbbc"]
    [Just [" 0: a"]]
,


testRegex ".{3,4}" []
    ["abbbbc"]
    [Just [" 0: abbb"]]
,


testRegex "ab{0,}bc" []
    ["abbbbc"]
    [Just [" 0: abbbbc"]]
,


testRegex "ab+bc" []
    ["abbc",
     "*** Failers",
     "abc",
     "abq"]
    [Just [" 0: abbc"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "ab{1,}bc" []
    []
    []
,


testRegex "ab+bc" []
    ["abbbbc"]
    [Just [" 0: abbbbc"]]
,


testRegex "ab{1,}bc" []
    ["abbbbc"]
    [Just [" 0: abbbbc"]]
,


testRegex "ab{1,3}bc" []
    ["abbbbc"]
    [Just [" 0: abbbbc"]]
,


testRegex "ab{3,4}bc" []
    ["abbbbc"]
    [Just [" 0: abbbbc"]]
,


testRegex "ab{4,5}bc" []
    ["*** Failers",
     "abq",
     "abbbbc"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "ab?bc" []
    ["abbc",
     "abc"]
    [Just [" 0: abbc"],
     Just [" 0: abc"]]
,


testRegex "ab{0,1}bc" []
    ["abc"]
    [Just [" 0: abc"]]
,


testRegex "ab?bc" []
    []
    []
,


testRegex "ab?c" []
    ["abc"]
    [Just [" 0: abc"]]
,


testRegex "ab{0,1}c" []
    ["abc"]
    [Just [" 0: abc"]]
,


testRegex "^abc$" []
    ["abc",
     "*** Failers",
     "abbbbc",
     "abcc"]
    [Just [" 0: abc"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^abc" []
    ["abcc"]
    [Just [" 0: abc"]]
,


testRegex "^abc$" []
    []
    []
,


testRegex "abc$" []
    ["aabc",
     "*** Failers",
     "aabc",
     "aabcd"]
    [Just [" 0: abc"],
     Nothing,
     Just [" 0: abc"],
     Nothing]
,


testRegex "^" []
    ["abc"]
    [Just [" 0: "]]
,


testRegex "$" []
    ["abc"]
    [Just [" 0: "]]
,


testRegex "a.c" []
    ["abc",
     "axc"]
    [Just [" 0: abc"],
     Just [" 0: axc"]]
,


testRegex "a.*c" []
    ["axyzc"]
    [Just [" 0: axyzc"]]
,


testRegex "a[bc]d" []
    ["abd",
     "*** Failers",
     "axyzd",
     "abc"]
    [Just [" 0: abd"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "a[b-d]e" []
    ["ace"]
    [Just [" 0: ace"]]
,


testRegex "a[b-d]" []
    ["aac"]
    [Just [" 0: ac"]]
,


testRegex "a[-b]" []
    ["a-"]
    [Just [" 0: a-"]]
,


testRegex "a[b-]" []
    ["a-"]
    [Just [" 0: a-"]]
,


testRegex "a]" []
    ["a]"]
    [Just [" 0: a]"]]
,


testRegex "a[]]b" []
    ["a]b"]
    [Just [" 0: a]b"]]
,


testRegex "a[^bc]d" []
    ["aed",
     "*** Failers",
     "abd",
     "abd"]
    [Just [" 0: aed"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "a[^-b]c" []
    ["adc"]
    [Just [" 0: adc"]]
,


testRegex "a[^]b]c" []
    ["adc",
     "*** Failers",
     "a-c",
     "a]c"]
    [Just [" 0: adc"],
     Nothing,
     Just [" 0: a-c"],
     Nothing]
,


testRegex "\\ba\\b" []
    ["a-",
     "-a",
     "-a-"]
    [Just [" 0: a"],
     Just [" 0: a"],
     Just [" 0: a"]]
,


testRegex "\\by\\b" []
    ["*** Failers",
     "xy",
     "yz",
     "xyz"]
    [Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "\\Ba\\B" []
    ["*** Failers",
     "a-",
     "-a",
     "-a-"]
    [Just [" 0: a"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "\\By\\b" []
    ["xy"]
    [Just [" 0: y"]]
,


testRegex "\\by\\B" []
    ["yz"]
    [Just [" 0: y"]]
,


testRegex "\\By\\B" []
    ["xyz"]
    [Just [" 0: y"]]
,


testRegex "\\w" []
    ["a"]
    [Just [" 0: a"]]
,


testRegex "\\W" []
    ["-",
     "*** Failers",
     "-",
     "a"]
    [Just [" 0: -"],
     Just [" 0: *"],
     Just [" 0: -"],
     Nothing]
,


testRegex "a\\sb" []
    ["a b"]
    [Just [" 0: a b"]]
,


testRegex "a\\Sb" []
    ["a-b",
     "*** Failers",
     "a-b",
     "a b"]
    [Just [" 0: a-b"],
     Nothing,
     Just [" 0: a-b"],
     Nothing]
,


testRegex "\\d" []
    ["1"]
    [Just [" 0: 1"]]
,


testRegex "\\D" []
    ["-",
     "*** Failers",
     "-",
     "1"]
    [Just [" 0: -"],
     Just [" 0: *"],
     Just [" 0: -"],
     Nothing]
,


testRegex "[\\w]" []
    ["a"]
    [Just [" 0: a"]]
,


testRegex "[\\W]" []
    ["-",
     "*** Failers",
     "-",
     "a"]
    [Just [" 0: -"],
     Just [" 0: *"],
     Just [" 0: -"],
     Nothing]
,


testRegex "a[\\s]b" []
    ["a b"]
    [Just [" 0: a b"]]
,


testRegex "a[\\S]b" []
    ["a-b",
     "*** Failers",
     "a-b",
     "a b"]
    [Just [" 0: a-b"],
     Nothing,
     Just [" 0: a-b"],
     Nothing]
,


testRegex "[\\d]" []
    ["1"]
    [Just [" 0: 1"]]
,


testRegex "[\\D]" []
    ["-",
     "*** Failers",
     "-",
     "1"]
    [Just [" 0: -"],
     Just [" 0: *"],
     Just [" 0: -"],
     Nothing]
,


testRegex "ab|cd" []
    ["abc",
     "abcd"]
    [Just [" 0: ab"],
     Just [" 0: ab"]]
,


testRegex "()ef" []
    ["def"]
    [Just [" 0: ef"],
     Just [" 1: "]]
,


testRegex "$b" []
    []
    []
,


testRegex "a\\(b" []
    ["a(b"]
    [Just [" 0: a(b"]]
,


testRegex "a\\(*b" []
    ["ab",
     "a((b"]
    [Just [" 0: ab"],
     Just [" 0: a((b"]]
,


testRegex "a\\\\b" []
    ["a\\b"]
    [Nothing]
,


testRegex "((a))" []
    ["abc"]
    [Just [" 0: a"],
     Just [" 1: a"],
     Just [" 2: a"]]
,


testRegex "(a)b(c)" []
    ["abc"]
    [Just [" 0: abc"],
     Just [" 1: a"],
     Just [" 2: c"]]
,


testRegex "a+b+c" []
    ["aabbabc"]
    [Just [" 0: abc"]]
,


testRegex "a{1,}b{1,}c" []
    ["aabbabc"]
    [Just [" 0: abc"]]
,


testRegex "a.+?c" []
    ["abcabc"]
    [Just [" 0: abc"]]
,


testRegex "(a+|b)*" []
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: b"]]
,


testRegex "(a+|b){0,}" []
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: b"]]
,


testRegex "(a+|b)+" []
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: b"]]
,


testRegex "(a+|b){1,}" []
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: b"]]
,


testRegex "(a+|b)?" []
    ["ab"]
    [Just [" 0: a"],
     Just [" 1: a"]]
,


testRegex "(a+|b){0,1}" []
    ["ab"]
    [Just [" 0: a"],
     Just [" 1: a"]]
,


testRegex "[^ab]*" []
    ["cde"]
    [Just [" 0: cde"]]
,


testRegex "abc" []
    ["*** Failers",
     "b",
     ""]
    [Nothing,
     Nothing]
,


testRegex "a*" []
    [""]
    []
,


testRegex "([abc])*d" []
    ["abbbcd"]
    [Just [" 0: abbbcd"],
     Just [" 1: c"]]
,


testRegex "([abc])*bcd" []
    ["abcd"]
    [Just [" 0: abcd"],
     Just [" 1: a"]]
,


testRegex "a|b|c|d|e" []
    ["e"]
    [Just [" 0: e"]]
,


testRegex "(a|b|c|d|e)f" []
    ["ef"]
    [Just [" 0: ef"],
     Just [" 1: e"]]
,


testRegex "abcd*efg" []
    ["abcdefg"]
    [Just [" 0: abcdefg"]]
,


testRegex "ab*" []
    ["xabyabbbz",
     "xayabbbz"]
    [Just [" 0: ab"],
     Just [" 0: a"]]
,


testRegex "(ab|cd)e" []
    ["abcde"]
    [Just [" 0: cde"],
     Just [" 1: cd"]]
,


testRegex "[abhgefdc]ij" []
    ["hij"]
    [Just [" 0: hij"]]
,


testRegex "^(ab|cd)e" []
    []
    []
,


testRegex "(abc|)ef" []
    ["abcdef"]
    [Just [" 0: ef"],
     Just [" 1: "]]
,


testRegex "(a|b)c*d" []
    ["abcd"]
    [Just [" 0: bcd"],
     Just [" 1: b"]]
,


testRegex "(ab|ab*)bc" []
    ["abc"]
    [Just [" 0: abc"],
     Just [" 1: a"]]
,


testRegex "a([bc]*)c*" []
    ["abc"]
    [Just [" 0: abc"],
     Just [" 1: bc"]]
,


testRegex "a([bc]*)(c*d)" []
    ["abcd"]
    [Just [" 0: abcd"],
     Just [" 1: bc"],
     Just [" 2: d"]]
,


testRegex "a([bc]+)(c*d)" []
    ["abcd"]
    [Just [" 0: abcd"],
     Just [" 1: bc"],
     Just [" 2: d"]]
,


testRegex "a([bc]*)(c+d)" []
    ["abcd"]
    [Just [" 0: abcd"],
     Just [" 1: b"],
     Just [" 2: cd"]]
,


testRegex "a[bcd]*dcdcde" []
    ["adcdcde"]
    [Just [" 0: adcdcde"]]
,


testRegex "a[bcd]+dcdcde" []
    ["*** Failers",
     "abcde",
     "adcdcde"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "(ab|a)b*c" []
    ["abc"]
    [Just [" 0: abc"],
     Just [" 1: ab"]]
,


testRegex "((a)(b)c)(d)" []
    ["abcd"]
    [Just [" 0: abcd"],
     Just [" 1: abc"],
     Just [" 2: a"],
     Just [" 3: b"],
     Just [" 4: d"]]
,


testRegex "[a-zA-Z_][a-zA-Z0-9_]*" []
    ["alpha"]
    [Just [" 0: alpha"]]
,


testRegex "^a(bc+|b[eh])g|.h$" []
    ["abh"]
    [Just [" 0: bh"]]
,


testRegex "(bc+d$|ef*g.|h?i(j|k))" []
    ["effgz",
     "ij",
     "reffgz",
     "*** Failers",
     "effg",
     "bcdd"]
    [Just [" 0: effgz"],
     Just [" 1: effgz"],
     Just [" 0: ij"],
     Just [" 1: ij"],
     Just [" 2: j"],
     Just [" 0: effgz"],
     Just [" 1: effgz"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "((((((((((a))))))))))" []
    ["a"]
    [Just [" 0: a"],
     Just [" 1: a"],
     Just [" 2: a"],
     Just [" 3: a"],
     Just [" 4: a"],
     Just [" 5: a"],
     Just [" 6: a"],
     Just [" 7: a"],
     Just [" 8: a"],
     Just [" 9: a"],
     Just ["10: a"]]
,


testRegex "((((((((((a))))))))))\\10" []
    ["aa"]
    [Just [" 0: aa"],
     Just [" 1: a"],
     Just [" 2: a"],
     Just [" 3: a"],
     Just [" 4: a"],
     Just [" 5: a"],
     Just [" 6: a"],
     Just [" 7: a"],
     Just [" 8: a"],
     Just [" 9: a"],
     Just ["10: a"]]
,


testRegex "(((((((((a)))))))))" []
    ["a"]
    [Just [" 0: a"],
     Just [" 1: a"],
     Just [" 2: a"],
     Just [" 3: a"],
     Just [" 4: a"],
     Just [" 5: a"],
     Just [" 6: a"],
     Just [" 7: a"],
     Just [" 8: a"],
     Just [" 9: a"]]
,


testRegex "multiple words of text" []
    ["*** Failers",
     "aa",
     "uh-uh"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "multiple words" []
    ["multiple words, yeah"]
    [Just [" 0: multiple words"]]
,


testRegex "(.*)c(.*)" []
    ["abcde"]
    [Just [" 0: abcde"],
     Just [" 1: ab"],
     Just [" 2: de"]]
,


testRegex "\\((.*), (.*)\\)" []
    ["(a, b)"]
    [Just [" 0: (a, b)"],
     Just [" 1: a"],
     Just [" 2: b"]]
,


testRegex "[k]" []
    []
    []
,


testRegex "abcd" []
    ["abcd"]
    [Just [" 0: abcd"]]
,


testRegex "a(bc)d" []
    ["abcd"]
    [Just [" 0: abcd"],
     Just [" 1: bc"]]
,


testRegex "a[-]?c" []
    ["ac"]
    [Just [" 0: ac"]]
,


testRegex "(abc)\\1" []
    ["abcabc"]
    [Just [" 0: abcabc"],
     Just [" 1: abc"]]
,


testRegex "([a-c]*)\\1" []
    ["abcabc"]
    [Just [" 0: abcabc"],
     Just [" 1: abc"]]
,


testRegex "(a)|\\1" []
    ["a",
     "*** Failers",
     "ab",
     "x"]
    [Just [" 0: a"],
     Just [" 1: a"],
     Just [" 0: a"],
     Just [" 1: a"],
     Just [" 0: a"],
     Just [" 1: a"],
     Nothing]
,


testRegex "(([a-c])b*?\\2)*" []
    ["ababbbcbc"]
    [Just [" 0: ababb"],
     Just [" 1: bb"],
     Just [" 2: b"]]
,


testRegex "(([a-c])b*?\\2){3}" []
    ["ababbbcbc"]
    [Just [" 0: ababbbcbc"],
     Just [" 1: cbc"],
     Just [" 2: c"]]
,


testRegex "((\\3|b)\\2(a)x)+" []
    ["aaaxabaxbaaxbbax"]
    [Just [" 0: bbax"],
     Just [" 1: bbax"],
     Just [" 2: b"],
     Just [" 3: a"]]
,


testRegex "((\\3|b)\\2(a)){2,}" []
    ["bbaababbabaaaaabbaaaabba"]
    [Just [" 0: bbaaaabba"],
     Just [" 1: bba"],
     Just [" 2: b"],
     Just [" 3: a"]]
,


testRegex "abc" [caseless]
    ["ABC",
     "XABCY",
     "ABABC",
     "*** Failers",
     "aaxabxbaxbbx",
     "XBC",
     "AXC",
     "ABX"]
    [Just [" 0: ABC"],
     Just [" 0: ABC"],
     Just [" 0: ABC"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "ab*c" [caseless]
    ["ABC"]
    [Just [" 0: ABC"]]
,


testRegex "ab*bc" [caseless]
    ["ABC",
     "ABBC"]
    [Just [" 0: ABC"],
     Just [" 0: ABBC"]]
,


testRegex "ab*?bc" [caseless]
    ["ABBBBC"]
    [Just [" 0: ABBBBC"]]
,


testRegex "ab{0,}?bc" [caseless]
    ["ABBBBC"]
    [Just [" 0: ABBBBC"]]
,


testRegex "ab+?bc" [caseless]
    ["ABBC"]
    [Just [" 0: ABBC"]]
,


testRegex "ab+bc" [caseless]
    ["*** Failers",
     "ABC",
     "ABQ"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "ab{1,}bc" [caseless]
    []
    []
,


testRegex "ab+bc" [caseless]
    ["ABBBBC"]
    [Just [" 0: ABBBBC"]]
,


testRegex "ab{1,}?bc" [caseless]
    ["ABBBBC"]
    [Just [" 0: ABBBBC"]]
,


testRegex "ab{1,3}?bc" [caseless]
    ["ABBBBC"]
    [Just [" 0: ABBBBC"]]
,


testRegex "ab{3,4}?bc" [caseless]
    ["ABBBBC"]
    [Just [" 0: ABBBBC"]]
,


testRegex "ab{4,5}?bc" [caseless]
    ["*** Failers",
     "ABQ",
     "ABBBBC"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "ab??bc" [caseless]
    ["ABBC",
     "ABC"]
    [Just [" 0: ABBC"],
     Just [" 0: ABC"]]
,


testRegex "ab{0,1}?bc" [caseless]
    ["ABC"]
    [Just [" 0: ABC"]]
,


testRegex "ab??bc" [caseless]
    []
    []
,


testRegex "ab??c" [caseless]
    ["ABC"]
    [Just [" 0: ABC"]]
,


testRegex "ab{0,1}?c" [caseless]
    ["ABC"]
    [Just [" 0: ABC"]]
,


testRegex "^abc$" [caseless]
    ["ABC",
     "*** Failers",
     "ABBBBC",
     "ABCC"]
    [Just [" 0: ABC"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^abc" [caseless]
    ["ABCC"]
    [Just [" 0: ABC"]]
,


testRegex "^abc$" [caseless]
    []
    []
,


testRegex "abc$" [caseless]
    ["AABC"]
    [Just [" 0: ABC"]]
,


testRegex "^" [caseless]
    ["ABC"]
    [Just [" 0: "]]
,


testRegex "$" [caseless]
    ["ABC"]
    [Just [" 0: "]]
,


testRegex "a.c" [caseless]
    ["ABC",
     "AXC"]
    [Just [" 0: ABC"],
     Just [" 0: AXC"]]
,


testRegex "a.*?c" [caseless]
    ["AXYZC"]
    [Just [" 0: AXYZC"]]
,


testRegex "a.*c" [caseless]
    ["*** Failers",
     "AABC",
     "AXYZD"]
    [Nothing,
     Just [" 0: AABC"],
     Nothing]
,


testRegex "a[bc]d" [caseless]
    ["ABD"]
    [Just [" 0: ABD"]]
,


testRegex "a[b-d]e" [caseless]
    ["ACE",
     "*** Failers",
     "ABC",
     "ABD"]
    [Just [" 0: ACE"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "a[b-d]" [caseless]
    ["AAC"]
    [Just [" 0: AC"]]
,


testRegex "a[-b]" [caseless]
    ["A-"]
    [Just [" 0: A-"]]
,


testRegex "a[b-]" [caseless]
    ["A-"]
    [Just [" 0: A-"]]
,


testRegex "a]" [caseless]
    ["A]"]
    [Just [" 0: A]"]]
,


testRegex "a[]]b" [caseless]
    ["A]B"]
    [Just [" 0: A]B"]]
,


testRegex "a[^bc]d" [caseless]
    ["AED"]
    [Just [" 0: AED"]]
,


testRegex "a[^-b]c" [caseless]
    ["ADC",
     "*** Failers",
     "ABD",
     "A-C"]
    [Just [" 0: ADC"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "a[^]b]c" [caseless]
    ["ADC"]
    [Just [" 0: ADC"]]
,


testRegex "ab|cd" [caseless]
    ["ABC",
     "ABCD"]
    [Just [" 0: AB"],
     Just [" 0: AB"]]
,


testRegex "()ef" [caseless]
    ["DEF"]
    [Just [" 0: EF"],
     Just [" 1: "]]
,


testRegex "$b" [caseless]
    ["*** Failers",
     "A]C",
     "B"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "a\\(b" [caseless]
    ["A(B"]
    [Just [" 0: A(B"]]
,


testRegex "a\\(*b" [caseless]
    ["AB",
     "A((B"]
    [Just [" 0: AB"],
     Just [" 0: A((B"]]
,


testRegex "a\\\\b" [caseless]
    ["A\\B"]
    [Nothing]
,


testRegex "((a))" [caseless]
    ["ABC"]
    [Just [" 0: A"],
     Just [" 1: A"],
     Just [" 2: A"]]
,


testRegex "(a)b(c)" [caseless]
    ["ABC"]
    [Just [" 0: ABC"],
     Just [" 1: A"],
     Just [" 2: C"]]
,


testRegex "a+b+c" [caseless]
    ["AABBABC"]
    [Just [" 0: ABC"]]
,


testRegex "a{1,}b{1,}c" [caseless]
    ["AABBABC"]
    [Just [" 0: ABC"]]
,


testRegex "a.+?c" [caseless]
    ["ABCABC"]
    [Just [" 0: ABC"]]
,


testRegex "a.*?c" [caseless]
    ["ABCABC"]
    [Just [" 0: ABC"]]
,


testRegex "a.{0,5}?c" [caseless]
    ["ABCABC"]
    [Just [" 0: ABC"]]
,


testRegex "(a+|b)*" [caseless]
    ["AB"]
    [Just [" 0: AB"],
     Just [" 1: B"]]
,


testRegex "(a+|b){0,}" [caseless]
    ["AB"]
    [Just [" 0: AB"],
     Just [" 1: B"]]
,


testRegex "(a+|b)+" [caseless]
    ["AB"]
    [Just [" 0: AB"],
     Just [" 1: B"]]
,


testRegex "(a+|b){1,}" [caseless]
    ["AB"]
    [Just [" 0: AB"],
     Just [" 1: B"]]
,


testRegex "(a+|b)?" [caseless]
    ["AB"]
    [Just [" 0: A"],
     Just [" 1: A"]]
,


testRegex "(a+|b){0,1}" [caseless]
    ["AB"]
    [Just [" 0: A"],
     Just [" 1: A"]]
,


testRegex "(a+|b){0,1}?" [caseless]
    ["AB"]
    [Just [" 0: "]]
,


testRegex "[^ab]*" [caseless]
    ["CDE"]
    [Just [" 0: CDE"]]
,


testRegex "abc" [caseless]
    []
    []
,


testRegex "a*" [caseless]
    [""]
    []
,


testRegex "([abc])*d" [caseless]
    ["ABBBCD"]
    [Just [" 0: ABBBCD"],
     Just [" 1: C"]]
,


testRegex "([abc])*bcd" [caseless]
    ["ABCD"]
    [Just [" 0: ABCD"],
     Just [" 1: A"]]
,


testRegex "a|b|c|d|e" [caseless]
    ["E"]
    [Just [" 0: E"]]
,


testRegex "(a|b|c|d|e)f" [caseless]
    ["EF"]
    [Just [" 0: EF"],
     Just [" 1: E"]]
,


testRegex "abcd*efg" [caseless]
    ["ABCDEFG"]
    [Just [" 0: ABCDEFG"]]
,


testRegex "ab*" [caseless]
    ["XABYABBBZ",
     "XAYABBBZ"]
    [Just [" 0: AB"],
     Just [" 0: A"]]
,


testRegex "(ab|cd)e" [caseless]
    ["ABCDE"]
    [Just [" 0: CDE"],
     Just [" 1: CD"]]
,


testRegex "[abhgefdc]ij" [caseless]
    ["HIJ"]
    [Just [" 0: HIJ"]]
,


testRegex "^(ab|cd)e" [caseless]
    ["ABCDE"]
    [Nothing]
,


testRegex "(abc|)ef" [caseless]
    ["ABCDEF"]
    [Just [" 0: EF"],
     Just [" 1: "]]
,


testRegex "(a|b)c*d" [caseless]
    ["ABCD"]
    [Just [" 0: BCD"],
     Just [" 1: B"]]
,


testRegex "(ab|ab*)bc" [caseless]
    ["ABC"]
    [Just [" 0: ABC"],
     Just [" 1: A"]]
,


testRegex "a([bc]*)c*" [caseless]
    ["ABC"]
    [Just [" 0: ABC"],
     Just [" 1: BC"]]
,


testRegex "a([bc]*)(c*d)" [caseless]
    ["ABCD"]
    [Just [" 0: ABCD"],
     Just [" 1: BC"],
     Just [" 2: D"]]
,


testRegex "a([bc]+)(c*d)" [caseless]
    ["ABCD"]
    [Just [" 0: ABCD"],
     Just [" 1: BC"],
     Just [" 2: D"]]
,


testRegex "a([bc]*)(c+d)" [caseless]
    ["ABCD"]
    [Just [" 0: ABCD"],
     Just [" 1: B"],
     Just [" 2: CD"]]
,


testRegex "a[bcd]*dcdcde" [caseless]
    ["ADCDCDE"]
    [Just [" 0: ADCDCDE"]]
,


testRegex "a[bcd]+dcdcde" [caseless]
    []
    []
,


testRegex "(ab|a)b*c" [caseless]
    ["ABC"]
    [Just [" 0: ABC"],
     Just [" 1: AB"]]
,


testRegex "((a)(b)c)(d)" [caseless]
    ["ABCD"]
    [Just [" 0: ABCD"],
     Just [" 1: ABC"],
     Just [" 2: A"],
     Just [" 3: B"],
     Just [" 4: D"]]
,


testRegex "[a-zA-Z_][a-zA-Z0-9_]*" [caseless]
    ["ALPHA"]
    [Just [" 0: ALPHA"]]
,


testRegex "^a(bc+|b[eh])g|.h$" [caseless]
    ["ABH"]
    [Just [" 0: BH"]]
,


testRegex "(bc+d$|ef*g.|h?i(j|k))" [caseless]
    ["EFFGZ",
     "IJ",
     "REFFGZ",
     "*** Failers",
     "ADCDCDE",
     "EFFG",
     "BCDD"]
    [Just [" 0: EFFGZ"],
     Just [" 1: EFFGZ"],
     Just [" 0: IJ"],
     Just [" 1: IJ"],
     Just [" 2: J"],
     Just [" 0: EFFGZ"],
     Just [" 1: EFFGZ"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "((((((((((a))))))))))" [caseless]
    ["A"]
    [Just [" 0: A"],
     Just [" 1: A"],
     Just [" 2: A"],
     Just [" 3: A"],
     Just [" 4: A"],
     Just [" 5: A"],
     Just [" 6: A"],
     Just [" 7: A"],
     Just [" 8: A"],
     Just [" 9: A"],
     Just ["10: A"]]
,


testRegex "((((((((((a))))))))))\\10" [caseless]
    ["AA"]
    [Just [" 0: AA"],
     Just [" 1: A"],
     Just [" 2: A"],
     Just [" 3: A"],
     Just [" 4: A"],
     Just [" 5: A"],
     Just [" 6: A"],
     Just [" 7: A"],
     Just [" 8: A"],
     Just [" 9: A"],
     Just ["10: A"]]
,


testRegex "(((((((((a)))))))))" [caseless]
    ["A"]
    [Just [" 0: A"],
     Just [" 1: A"],
     Just [" 2: A"],
     Just [" 3: A"],
     Just [" 4: A"],
     Just [" 5: A"],
     Just [" 6: A"],
     Just [" 7: A"],
     Just [" 8: A"],
     Just [" 9: A"]]
,


testRegex "(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))" [caseless]
    ["A"]
    [Just [" 0: A"],
     Just [" 1: A"]]
,


testRegex "(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))" [caseless]
    ["C"]
    [Just [" 0: C"],
     Just [" 1: C"]]
,


testRegex "multiple words of text" [caseless]
    ["*** Failers",
     "AA",
     "UH-UH"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "multiple words" [caseless]
    ["MULTIPLE WORDS, YEAH"]
    [Just [" 0: MULTIPLE WORDS"]]
,


testRegex "(.*)c(.*)" [caseless]
    ["ABCDE"]
    [Just [" 0: ABCDE"],
     Just [" 1: AB"],
     Just [" 2: DE"]]
,


testRegex "\\((.*), (.*)\\)" [caseless]
    ["(A, B)"]
    [Just [" 0: (A, B)"],
     Just [" 1: A"],
     Just [" 2: B"]]
,


testRegex "[k]" [caseless]
    []
    []
,


testRegex "abcd" [caseless]
    ["ABCD"]
    [Just [" 0: ABCD"]]
,


testRegex "a(bc)d" [caseless]
    ["ABCD"]
    [Just [" 0: ABCD"],
     Just [" 1: BC"]]
,


testRegex "a[-]?c" [caseless]
    ["AC"]
    [Just [" 0: AC"]]
,


testRegex "(abc)\\1" [caseless]
    ["ABCABC"]
    [Just [" 0: ABCABC"],
     Just [" 1: ABC"]]
,


testRegex "([a-c]*)\\1" [caseless]
    ["ABCABC"]
    [Just [" 0: ABCABC"],
     Just [" 1: ABC"]]
,


testRegex "a(?!b)." []
    ["abad"]
    [Just [" 0: ad"]]
,


testRegex "a(?=d)." []
    ["abad"]
    [Just [" 0: ad"]]
,


testRegex "a(?=c|d)." []
    ["abad"]
    [Just [" 0: ad"]]
,


testRegex "a(?:b|c|d)(.)" []
    ["ace"]
    [Just [" 0: ace"],
     Just [" 1: e"]]
,


testRegex "a(?:b|c|d)*(.)" []
    ["ace"]
    [Just [" 0: ace"],
     Just [" 1: e"]]
,


testRegex "a(?:b|c|d)+?(.)" []
    ["ace",
     "acdbcdbe"]
    [Just [" 0: ace"],
     Just [" 1: e"],
     Just [" 0: acd"],
     Just [" 1: d"]]
,


testRegex "a(?:b|c|d)+(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdbe"],
     Just [" 1: e"]]
,


testRegex "a(?:b|c|d){2}(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdb"],
     Just [" 1: b"]]
,


testRegex "a(?:b|c|d){4,5}(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdb"],
     Just [" 1: b"]]
,


testRegex "a(?:b|c|d){4,5}?(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcd"],
     Just [" 1: d"]]
,


testRegex "((foo)|(bar))*" []
    ["foobar"]
    [Just [" 0: foobar"],
     Just [" 1: bar"],
     Just [" 2: foo"],
     Just [" 3: bar"]]
,


testRegex "a(?:b|c|d){6,7}(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdbe"],
     Just [" 1: e"]]
,


testRegex "a(?:b|c|d){6,7}?(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdbe"],
     Just [" 1: e"]]
,


testRegex "a(?:b|c|d){5,6}(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdbe"],
     Just [" 1: e"]]
,


testRegex "a(?:b|c|d){5,6}?(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdb"],
     Just [" 1: b"]]
,


testRegex "a(?:b|c|d){5,7}(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdbe"],
     Just [" 1: e"]]
,


testRegex "a(?:b|c|d){5,7}?(.)" []
    ["acdbcdbe"]
    [Just [" 0: acdbcdb"],
     Just [" 1: b"]]
,


testRegex "a(?:b|(c|e){1,2}?|d)+?(.)" []
    ["ace"]
    [Just [" 0: ace"],
     Just [" 1: c"],
     Just [" 2: e"]]
,


testRegex "^(.+)?B" []
    ["AB"]
    [Just [" 0: AB"],
     Just [" 1: A"]]
,


testRegex "^([^a-z])|(\\^)$" []
    ["."]
    [Just [" 0: ."],
     Just [" 1: ."]]
,


testRegex "^[<>]&" []
    ["<&OUT"]
    [Just [" 0: <&"]]
,


testRegex "^(a\\1?){4}$" []
    ["aaaaaaaaaa",
     "*** Failers",
     "AB",
     "aaaaaaaaa",
     "aaaaaaaaaaa"]
    [Just [" 0: aaaaaaaaaa"],
     Just [" 1: aaaa"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^(a(?(1)\\1)){4}$" []
    ["aaaaaaaaaa",
     "*** Failers",
     "aaaaaaaaa",
     "aaaaaaaaaaa"]
    [Just [" 0: aaaaaaaaaa"],
     Just [" 1: aaaa"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?:(f)(o)(o)|(b)(a)(r))*" []
    ["foobar"]
    [Just [" 0: foobar"],
     Just [" 1: f"],
     Just [" 2: o"],
     Just [" 3: o"],
     Just [" 4: b"],
     Just [" 5: a"],
     Just [" 6: r"]]
,


testRegex "(?<=a)b" []
    ["ab",
     "*** Failers",
     "cb",
     "b"]
    [Just [" 0: b"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?<!c)b" []
    ["ab",
     "b",
     "b"]
    [Just [" 0: b"],
     Just [" 0: b"],
     Just [" 0: b"]]
,


testRegex "(?:..)*a" []
    ["aba"]
    [Just [" 0: aba"]]
,


testRegex "(?:..)*?a" []
    ["aba"]
    [Just [" 0: a"]]
,


testRegex "^(?:b|a(?=(.)))*\\1" []
    ["abc"]
    [Just [" 0: ab"],
     Just [" 1: b"]]
,


testRegex "^(){3,5}" []
    ["abc"]
    [Just [" 0: "],
     Just [" 1: "]]
,


testRegex "^(a+)*ax" []
    ["aax"]
    [Just [" 0: aax"],
     Just [" 1: a"]]
,


testRegex "^((a|b)+)*ax" []
    ["aax"]
    [Just [" 0: aax"],
     Just [" 1: a"],
     Just [" 2: a"]]
,


testRegex "^((a|bc)+)*ax" []
    ["aax"]
    [Just [" 0: aax"],
     Just [" 1: a"],
     Just [" 2: a"]]
,


testRegex "(a|x)*ab" []
    ["cab"]
    [Just [" 0: ab"]]
,


testRegex "(a)*ab" []
    ["cab"]
    [Just [" 0: ab"]]
,


testRegex "(?:(?i)a)b" []
    ["ab"]
    [Just [" 0: ab"]]
,


testRegex "((?i)a)b" []
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: a"]]
,


testRegex "(?:(?i)a)b" []
    ["Ab"]
    [Just [" 0: Ab"]]
,


testRegex "((?i)a)b" []
    ["Ab"]
    [Just [" 0: Ab"],
     Just [" 1: A"]]
,


testRegex "(?:(?i)a)b" []
    ["*** Failers",
     "cb",
     "aB"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "((?i)a)b" []
    []
    []
,


testRegex "(?i:a)b" []
    ["ab"]
    [Just [" 0: ab"]]
,


testRegex "((?i:a))b" []
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: a"]]
,


testRegex "(?i:a)b" []
    ["Ab"]
    [Just [" 0: Ab"]]
,


testRegex "((?i:a))b" []
    ["Ab"]
    [Just [" 0: Ab"],
     Just [" 1: A"]]
,


testRegex "(?i:a)b" []
    ["*** Failers",
     "aB",
     "aB"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "((?i:a))b" []
    []
    []
,


testRegex "(?:(?-i)a)b" [caseless]
    ["ab"]
    [Just [" 0: ab"]]
,


testRegex "((?-i)a)b" [caseless]
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: a"]]
,


testRegex "(?:(?-i)a)b" [caseless]
    ["aB"]
    [Just [" 0: aB"]]
,


testRegex "((?-i)a)b" [caseless]
    ["aB"]
    [Just [" 0: aB"],
     Just [" 1: a"]]
,


testRegex "(?:(?-i)a)b" [caseless]
    ["*** Failers",
     "aB",
     "Ab"]
    [Nothing,
     Just [" 0: aB"],
     Nothing]
,


testRegex "((?-i)a)b" [caseless]
    []
    []
,


testRegex "(?:(?-i)a)b" [caseless]
    ["aB"]
    [Just [" 0: aB"]]
,


testRegex "((?-i)a)b" [caseless]
    ["aB"]
    [Just [" 0: aB"],
     Just [" 1: a"]]
,


testRegex "(?:(?-i)a)b" [caseless]
    ["*** Failers",
     "Ab",
     "AB"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "((?-i)a)b" [caseless]
    []
    []
,


testRegex "(?-i:a)b" [caseless]
    ["ab"]
    [Just [" 0: ab"]]
,


testRegex "((?-i:a))b" [caseless]
    ["ab"]
    [Just [" 0: ab"],
     Just [" 1: a"]]
,


testRegex "(?-i:a)b" [caseless]
    ["aB"]
    [Just [" 0: aB"]]
,


testRegex "((?-i:a))b" [caseless]
    ["aB"]
    [Just [" 0: aB"],
     Just [" 1: a"]]
,


testRegex "(?-i:a)b" [caseless]
    ["*** Failers",
     "AB",
     "Ab"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "((?-i:a))b" [caseless]
    []
    []
,


testRegex "(?-i:a)b" [caseless]
    ["aB"]
    [Just [" 0: aB"]]
,


testRegex "((?-i:a))b" [caseless]
    ["aB"]
    [Just [" 0: aB"],
     Just [" 1: a"]]
,


testRegex "(?-i:a)b" [caseless]
    ["*** Failers",
     "Ab",
     "AB"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "((?-i:a))b" [caseless]
    []
    []
,


testRegex "((?-i:a.))b" [caseless]
    ["*** Failers",
     "AB",
     "a\\nB"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "((?s-i:a.))b" [caseless]
    ["a\\nB"]
    [Just [" 0: a\\x0aB"],
     Just [" 1: a\\x0a"]]
,


testRegex "(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))" []
    ["cabbbb"]
    [Just [" 0: cabbbb"]]
,


testRegex "(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))" []
    ["caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"]
    [Just [" 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"]]
,


testRegex "(ab)\\d\\1" [caseless]
    ["Ab4ab",
     "ab4Ab"]
    [Just [" 0: Ab4ab"],
     Just [" 1: Ab"],
     Just [" 0: ab4Ab"],
     Just [" 1: ab"]]
,


testRegex "foo\\w*\\d{4}baz" []
    ["foobar1234baz"]
    [Just [" 0: foobar1234baz"]]
,


testRegex "x(~~)*(?:(?:F)?)?" []
    ["x~~"]
    [Just [" 0: x~~"],
     Just [" 1: ~~"]]
,


testRegex "^a(?#xxx){3}c" []
    ["aaac"]
    [Just [" 0: aaac"]]
,


testRegex "^a (?#xxx) (?#yyy) {3}c" [ERROR]
    ["aaac"]
    [Just [" 0: aaac"]]
,


testRegex "(?<![cd])b" []
    ["*** Failers",
     "B\\nB",
     "dbcb"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "(?<![cd])[ab]" []
    ["dbaacb"]
    [Just [" 0: a"]]
,


testRegex "(?<!(c|d))b" []
    []
    []
,


testRegex "(?<!(c|d))[ab]" []
    ["dbaacb"]
    [Just [" 0: a"]]
,


testRegex "(?<!cd)[ab]" []
    ["cdaccb"]
    [Just [" 0: b"]]
,


testRegex "^(?:a?b?)*$" []
    ["\\",
     "a",
     "ab",
     "aaa   ",
     "*** Failers",
     "dbcb",
     "a--",
     "aa-- "]
    [Just [" 0: "],
     Just [" 0: a"],
     Just [" 0: ab"],
     Just [" 0: aaa"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "((?s)^a(.))((?m)^b$)" []
    ["a\\nb\\nc\\n"]
    [Just [" 0: a\\x0ab"],
     Just [" 1: a\\x0a"],
     Just [" 2: \\x0a"],
     Just [" 3: b"]]
,


testRegex "((?m)^b$)" []
    ["a\\nb\\nc\\n"]
    [Just [" 0: b"],
     Just [" 1: b"]]
,


testRegex "(?m)^b" []
    ["a\\nb\\n"]
    [Just [" 0: b"]]
,


testRegex "(?m)^(b)" []
    ["a\\nb\\n"]
    [Just [" 0: b"],
     Just [" 1: b"]]
,


testRegex "((?m)^b)" []
    ["a\\nb\\n"]
    [Just [" 0: b"],
     Just [" 1: b"]]
,


testRegex "\\n((?m)^b)" []
    ["a\\nb\\n"]
    [Just [" 0: \\x0ab"],
     Just [" 1: b"]]
,


testRegex "((?s).)c(?!.)" []
    ["a\\nb\\nc\\n",
     "a\\nb\\nc\\n"]
    [Just [" 0: \\x0ac"],
     Just [" 1: \\x0a"],
     Just [" 0: \\x0ac"],
     Just [" 1: \\x0a"]]
,


testRegex "((?s)b.)c(?!.)" []
    ["a\\nb\\nc\\n",
     "a\\nb\\nc\\n"]
    [Just [" 0: b\\x0ac"],
     Just [" 1: b\\x0a"],
     Just [" 0: b\\x0ac"],
     Just [" 1: b\\x0a"]]
,


testRegex "^b" []
    []
    []
,


testRegex "()^b" []
    ["*** Failers",
     "a\\nb\\nc\\n",
     "a\\nb\\nc\\n"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "((?m)^b)" []
    ["a\\nb\\nc\\n"]
    [Just [" 0: b"],
     Just [" 1: b"]]
,


testRegex "(?(1)a|b)" []
    []
    []
,


testRegex "(?(1)b|a)" []
    ["a"]
    [Just [" 0: a"]]
,


testRegex "(x)?(?(1)a|b)" []
    ["*** Failers",
     "a",
     "a"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "(x)?(?(1)b|a)" []
    ["a"]
    [Just [" 0: a"]]
,


testRegex "()?(?(1)b|a)" []
    ["a"]
    [Just [" 0: a"]]
,


testRegex "()(?(1)b|a)" []
    []
    []
,


testRegex "()?(?(1)a|b)" []
    ["a"]
    [Just [" 0: a"],
     Just [" 1: "]]
,


testRegex "^(\\()?blah(?(1)(\\)))$" []
    ["(blah)",
     "blah",
     "*** Failers",
     "a",
     "blah)",
     "(blah"]
    [Just [" 0: (blah)"],
     Just [" 1: ("],
     Just [" 2: )"],
     Just [" 0: blah"],
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^(\\(+)?blah(?(1)(\\)))$" []
    ["(blah)",
     "blah",
     "*** Failers",
     "blah)",
     "(blah"]
    [Just [" 0: (blah)"],
     Just [" 1: ("],
     Just [" 2: )"],
     Just [" 0: blah"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?(?!a)a|b)" []
    []
    []
,


testRegex "(?(?!a)b|a)" []
    ["a"]
    [Just [" 0: a"]]
,


testRegex "(?(?=a)b|a)" []
    ["*** Failers",
     "a",
     "a"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "(?(?=a)a|b)" []
    ["a"]
    [Just [" 0: a"]]
,


testRegex "(?=(a+?))(\\1ab)" []
    ["aaab"]
    [Just [" 0: aab"],
     Just [" 1: a"],
     Just [" 2: aab"]]
,


testRegex "^(?=(a+?))\\1ab" []
    []
    []
,


testRegex "(\\w+:)+" []
    ["one:"]
    [Just [" 0: one:"],
     Just [" 1: one:"]]
,


testRegex "$(?<=^(a))" []
    ["a"]
    [Just [" 0: "],
     Just [" 1: a"]]
,


testRegex "(?=(a+?))(\\1ab)" []
    ["aaab"]
    [Just [" 0: aab"],
     Just [" 1: a"],
     Just [" 2: aab"]]
,


testRegex "^(?=(a+?))\\1ab" []
    ["*** Failers",
     "aaab",
     "aaab"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "([\\w:]+::)?(\\w+)$" []
    ["abcd",
     "xy:z:::abcd"]
    [Just [" 0: abcd"],
     Just [" 1: <unset>"],
     Just [" 2: abcd"],
     Just [" 0: xy:z:::abcd"],
     Just [" 1: xy:z:::"],
     Just [" 2: abcd"]]
,


testRegex "^[^bcd]*(c+)" []
    ["aexycd"]
    [Just [" 0: aexyc"],
     Just [" 1: c"]]
,


testRegex "(a*)b+" []
    ["caab"]
    [Just [" 0: aab"],
     Just [" 1: aa"]]
,


testRegex "([\\w:]+::)?(\\w+)$" []
    ["abcd",
     "xy:z:::abcd",
     "*** Failers",
     "abcd:",
     "abcd:"]
    [Just [" 0: abcd"],
     Just [" 1: <unset>"],
     Just [" 2: abcd"],
     Just [" 0: xy:z:::abcd"],
     Just [" 1: xy:z:::"],
     Just [" 2: abcd"],
     Just [" 0: Failers"],
     Just [" 1: <unset>"],
     Just [" 2: Failers"],
     Nothing,
     Nothing]
,


testRegex "^[^bcd]*(c+)" []
    ["aexycd"]
    [Just [" 0: aexyc"],
     Just [" 1: c"]]
,


testRegex "(>a+)ab" []
    []
    []
,


testRegex "(?>a+)b" []
    ["aaab"]
    [Just [" 0: aaab"]]
,


testRegex "([[:]+)" []
    ["a:[b]:"]
    [Just [" 0: :["],
     Just [" 1: :["]]
,


testRegex "([[=]+)" []
    ["a=[b]="]
    [Just [" 0: =["],
     Just [" 1: =["]]
,


testRegex "([[.]+)" []
    ["a.[b]."]
    [Just [" 0: .["],
     Just [" 1: .["]]
,


testRegex "((?>a+)b)" []
    ["aaab"]
    [Just [" 0: aaab"],
     Just [" 1: aaab"]]
,


testRegex "(?>(a+))b" []
    ["aaab"]
    [Just [" 0: aaab"],
     Just [" 1: aaa"]]
,


testRegex "((?>[^()]+)|\\([^()]*\\))+" []
    ["((abc(ade)ufh()()x"]
    [Just [" 0: abc(ade)ufh()()x"],
     Just [" 1: x"]]
,


testRegex "a\\Z" []
    ["*** Failers",
     "aaab",
     "a\\nb\\n"]
    [Nothing,
     Nothing,
     Nothing]
,


testRegex "b\\Z" []
    ["a\\nb\\n"]
    [Just [" 0: b"]]
,


testRegex "b\\z" []
    []
    []
,


testRegex "b\\Z" []
    ["a\\nb"]
    [Just [" 0: b"]]
,


testRegex "b\\z" []
    ["a\\nb",
     "*** Failers",
     "",
     "/^(?>(?(1)\\.|())[^\\W_](?>[a-z0-9-]*[^\\W_])?)+$/",
     "a",
     "abc",
     "a-b",
     "0-9 ",
     "a.b",
     "5.6.7  ",
     "the.quick.brown.fox",
     "a100.b200.300c  ",
     "12-ab.1245 ",
     "*** Failers",
     "\\",
     ".a",
     "-a",
     "a-",
     "a.  ",
     "a_b ",
     "a.-",
     "a..  ",
     "ab..bc ",
     "the.quick.brown.fox-",
     "the.quick.brown.fox.",
     "the.quick.brown.fox_",
     "the.quick.brown.fox+       "]
    [Just [" 0: b"],
     Nothing,
     Just ["/^(?>(?(1)\\.|())[^\\W_](?>[a-z0-9-]*[^\\W_])?)+$/"],
     Just [" 0: a"],
     Just [" 1: "],
     Just [" 0: abc"],
     Just [" 1: "],
     Just [" 0: a-b"],
     Just [" 1: "],
     Just [" 0: 0-9"],
     Just [" 1: "],
     Just [" 0: a.b"],
     Just [" 1: "],
     Just [" 0: 5.6.7"],
     Just [" 1: "],
     Just [" 0: the.quick.brown.fox"],
     Just [" 1: "],
     Just [" 0: a100.b200.300c"],
     Just [" 1: "],
     Just [" 0: 12-ab.1245"],
     Just [" 1: "],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(?>.*)(?<=(abcd|wxyz))" []
    ["alphabetabcd",
     "endingwxyz",
     "*** Failers",
     "a rather long string that doesn't end with one of them"]
    [Just [" 0: alphabetabcd"],
     Just [" 1: abcd"],
     Just [" 0: endingwxyz"],
     Just [" 1: wxyz"],
     Nothing,
     Nothing]
,


testRegex "word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword" []
    ["word cat dog elephant mussel cow horse canary baboon snake shark otherword",
     "word cat dog elephant mussel cow horse canary baboon snake shark",
     "",
     "/word (?>[a-zA-Z0-9]+ ){0,30}otherword/",
     "word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope"]
    [Just [" 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword"],
     Nothing,
     Just ["/word (?>[a-zA-Z0-9]+ ){0,30}otherword/"],
     Nothing]
,


testRegex "(?<=\\d{3}(?!999))foo" []
    ["999foo",
     "123999foo ",
     "*** Failers",
     "123abcfoo",
     "",
     "/(?<=(?!...999)\\d{3})foo/",
     "999foo",
     "123999foo ",
     "*** Failers",
     "123abcfoo"]
    [Just [" 0: foo"],
     Just [" 0: foo"],
     Nothing,
     Nothing,
     Just ["/(?<=(?!...999)\\d{3})foo/"],
     Just [" 0: foo"],
     Just [" 0: foo"],
     Nothing,
     Nothing]
,


testRegex "(?<=\\d{3}(?!999)...)foo" []
    ["123abcfoo",
     "123456foo ",
     "*** Failers",
     "123999foo  ",
     "",
     "/(?<=\\d{3}...)(?<!999)foo/",
     "123abcfoo   ",
     "123456foo ",
     "*** Failers",
     "123999foo  "]
    [Just [" 0: foo"],
     Just [" 0: foo"],
     Nothing,
     Nothing,
     Just ["/(?<=\\d{3}...)(?<!999)foo/"],
     Just [" 0: foo"],
     Just [" 0: foo"],
     Nothing,
     Nothing]
,


testRegex "ERROR" []
    ["([\\\"\\'])?                       # find single or double quote",
     "(?(1) (.*?)\\1 | ([^\\s]+))       # if quote found, match up to next matching",
     "# quote, otherwise match up to next space",
     "/isx",
     "<a href=abcd xyz",
     "<a href=\\\"abcd xyz pqr\\\" cats",
     "<a href=\\'abcd xyz pqr\\' cats"]
    [Just [" ([\\\"\\'])?                       # find single or double quote"],
     Just [" (?(1) (.*?)\\1 | ([^\\s]+))       # if quote found, match up to next matching"],
     Just ["/isx"],
     Just [" 0: <a href=abcd"],
     Just [" 1: <unset>"],
     Just [" 2: <unset>"],
     Just [" 3: abcd"],
     Just [" 0: <a href=\"abcd xyz pqr\""],
     Just [" 1: \""],
     Just [" 2: abcd xyz pqr"],
     Just [" 0: <a href='abcd xyz pqr'"],
     Just [" 1: '"],
     Just [" 2: abcd xyz pqr"]]
,


testRegex "ERROR" []
    ["([\"'])?                         # find single or double quote",
     "(?(1) (.*?)\\1 | (\\S+))          # if quote found, match up to next matching",
     "# quote, otherwise match up to next space",
     "/isx",
     "<a href=abcd xyz",
     "<a href=\\\"abcd xyz pqr\\\" cats",
     "<a href       =       \\'abcd xyz pqr\\' cats"]
    [Just [" ([\"'])?                         # find single or double quote"],
     Just [" (?(1) (.*?)\\1 | (\\S+))          # if quote found, match up to next matching"],
     Just ["/isx"],
     Just [" 0: <a href=abcd"],
     Just [" 1: <unset>"],
     Just [" 2: <unset>"],
     Just [" 3: abcd"],
     Just [" 0: <a href=\"abcd xyz pqr\""],
     Just [" 1: \""],
     Just [" 2: abcd xyz pqr"],
     Just [" 0: <a href       =       'abcd xyz pqr'"],
     Just [" 1: '"],
     Just [" 2: abcd xyz pqr"]]
,


testRegex "ERROR" []
    ["([\"'])?                         # find single or double quote",
     "(?(1) (.*?)\\1 | (\\S+))          # if quote found, match up to next matching",
     "# quote, otherwise match up to next space",
     "/isx",
     "<a href=abcd xyz",
     "<a href=\\\"abcd xyz pqr\\\" cats",
     "<a href       =       \\'abcd xyz pqr\\' cats"]
    [Just [" ([\"'])?                         # find single or double quote"],
     Just [" (?(1) (.*?)\\1 | (\\S+))          # if quote found, match up to next matching"],
     Just ["/isx"],
     Just [" 0: <a href=abcd"],
     Just [" 1: <unset>"],
     Just [" 2: <unset>"],
     Just [" 3: abcd"],
     Just [" 0: <a href=\"abcd xyz pqr\""],
     Just [" 1: \""],
     Just [" 2: abcd xyz pqr"],
     Just [" 0: <a href       =       'abcd xyz pqr'"],
     Just [" 1: '"],
     Just [" 2: abcd xyz pqr"]]
,


testRegex "((Z)+|A)*" []
    ["ZABCDEFG"]
    [Just [" 0: ZA"],
     Just [" 1: A"],
     Just [" 2: Z"]]
,


testRegex "(Z()|A)*" []
    ["ZABCDEFG"]
    [Just [" 0: ZA"],
     Just [" 1: A"],
     Just [" 2: "]]
,


testRegex "(Z(())|A)*" []
    ["ZABCDEFG"]
    [Just [" 0: ZA"],
     Just [" 1: A"],
     Just [" 2: "],
     Just [" 3: "]]
,


testRegex "((?>Z)+|A)*" []
    ["ZABCDEFG"]
    [Just [" 0: ZA"],
     Just [" 1: A"]]
,


testRegex "((?>)+|A)*" []
    ["ZABCDEFG"]
    [Just [" 0: "],
     Just [" 1: "]]
,


testRegex "a*" [ERROR]
    ["abbab"]
    [Just [" 0: a"],
     Just [" 0: "],
     Just [" 0: "],
     Just [" 0: a"],
     Just [" 0: "],
     Just [" 0: "]]
,


testRegex "^[a-\\d]" []
    ["abcde",
     "-things",
     "0digit",
     "*** Failers",
     "bcdef    "]
    [Just [" 0: a"],
     Just [" 0: -"],
     Just [" 0: 0"],
     Nothing,
     Nothing]
,


testRegex "^[\\d-a]" []
    ["abcde",
     "-things",
     "0digit",
     "*** Failers",
     "bcdef    ",
     "",
     "/[[:space:]]+/",
     "> \\x09\\x0a\\x0c\\x0d\\x0b<",
     "",
     "/[[:blank:]]+/",
     "> \\x09\\x0a\\x0c\\x0d\\x0b<",
     "",
     "/[\\s]+/",
     "> \\x09\\x0a\\x0c\\x0d\\x0b<",
     "",
     "/\\s+/",
     "> \\x09\\x0a\\x0c\\x0d\\x0b<",
     "",
     "/a\vb/x",
     "ab"]
    [Just [" 0: a"],
     Just [" 0: -"],
     Just [" 0: 0"],
     Nothing,
     Nothing,
     Just ["/[[:space:]]+/"],
     Just [" 0:  \\x09\\x0a\\x0c\\x0d\\x0b"],
     Just ["/[[:blank:]]+/"],
     Just [" 0:  \\x09"],
     Just ["/[\\s]+/"],
     Just [" 0:  \\x09\\x0a\\x0c\\x0d"],
     Just ["/\\s+/"],
     Just [" 0:  \\x09\\x0a\\x0c\\x0d"],
     Just ["/a\vb/x"],
     Nothing]
,


testRegex "(?!\\A)x" [ERROR]
    ["a\\nxb\\n"]
    [Just [" 0: x"]]
,


testRegex "(?!^)x" [ERROR]
    ["a\\nxb\\n"]
    [Nothing]
,


testRegex "abc\\Qabc\\Eabc" []
    ["abcabcabc",
     "",
     "/abc\\Q(*+|\\Eabc/",
     "abc(*+|abc "]
    [Just [" 0: abcabcabc"],
     Just ["/abc\\Q(*+|\\Eabc/"],
     Just [" 0: abc(*+|abc"]]
,


testRegex "   abc\\Q abc\\Eabc" [ERROR]
    ["abc abcabc",
     "*** Failers",
     "abcabcabc  ",
     "",
     "/abc#comment",
     "\\Q#not comment",
     "literal\\E/x",
     "abc#not comment\\n    literal     "]
    [Just [" 0: abc abcabc"],
     Nothing,
     Nothing,
     Just ["/abc#comment"],
     Just [" 0: abc#not comment\\x0a    literal"]]
,


testRegex "ERROR" []
    ["\\Q#not comment",
     "literal/x",
     "abc#not comment\\n    literal     "]
    [Just [" 0: abc#not comment\\x0a    literal"]]
,


testRegex "ERROR" []
    ["\\Q#not comment",
     "literal\\E #more comment",
     "/x",
     "abc#not comment\\n    literal     "]
    [Just [" 0: abc#not comment\\x0a    literal"]]
,


testRegex "ERROR" []
    ["\\Q#not comment",
     "literal\\E #more comment/x",
     "abc#not comment\\n    literal     "]
    [Just [" 0: abc#not comment\\x0a    literal"]]
,


testRegex "\\Qabc\\$xyz\\E" []
    ["abc\\\\\\$xyz"]
    [Just [" 0: abc\\$xyz"]]
,


testRegex "\\Qabc\\E\\$\\Qxyz\\E" []
    ["abc\\$xyz"]
    [Just [" 0: abc$xyz"]]
,


testRegex "\\Gabc" []
    ["abc",
     "*** Failers",
     "xyzabc  "]
    [Just [" 0: abc"],
     Nothing,
     Nothing]
,


testRegex "\\Gabc." [ERROR]
    ["abc1abc2xyzabc3"]
    [Just [" 0: abc1"],
     Just [" 0: abc2"]]
,


testRegex "abc." [ERROR]
    ["abc1abc2xyzabc3 "]
    [Just [" 0: abc1"],
     Just [" 0: abc2"],
     Just [" 0: abc3"]]
,


testRegex "a(?x: b c )d" []
    ["XabcdY",
     "*** Failers ",
     "Xa b c d Y "]
    [Just [" 0: abcd"],
     Nothing,
     Nothing]
,


testRegex "((?x)x y z | a b c)" []
    ["XabcY",
     "AxyzB "]
    [Just [" 0: abc"],
     Just [" 1: abc"],
     Just [" 0: xyz"],
     Just [" 1: xyz"]]
,


testRegex "(?i)AB(?-i)C" []
    ["XabCY",
     "*** Failers",
     "XabcY  "]
    [Just [" 0: abC"],
     Nothing,
     Nothing]
,


testRegex "((?i)AB(?-i)C|D)E" []
    ["abCE",
     "DE",
     "*** Failers",
     "abcE",
     "abCe  ",
     "dE",
     "De    "]
    [Just [" 0: abCE"],
     Just [" 1: abC"],
     Just [" 0: DE"],
     Just [" 1: D"],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "(.*)\\d+\\1" []
    ["abc123abc",
     "abc123bc "]
    [Just [" 0: abc123abc"],
     Just [" 1: abc"],
     Just [" 0: bc123bc"],
     Just [" 1: bc"]]
,


testRegex "(.*)\\d+\\1" [ERROR]
    ["abc123abc",
     "abc123bc ",
     "",
     "/((.*))\\d+\\1/",
     "abc123abc",
     "abc123bc  "]
    [Just [" 0: abc123abc"],
     Just [" 1: abc"],
     Just [" 0: bc123bc"],
     Just [" 1: bc"],
     Just ["/((.*))\\d+\\1/"],
     Just [" 0: abc123abc"],
     Just [" 1: abc"],
     Just [" 2: abc"],
     Just [" 0: bc123bc"],
     Just [" 1: bc"],
     Just [" 2: bc"]]
,


testRegex "-- This tests for an IPv6 address in the form where it can have up to --" []
    ["/-- eight components, one and only one of which is empty. This must be --/",
     "/-- an internal component. --/"]
    [Just ["/-- eight components, one and only one of which is empty. This must be --/"],
     Nothing,
     Just ["/-- an internal component. --/"],
     Nothing]
,


testRegex "ERROR" []
    ["(?:                         # start of item",
     "(?: [0-9a-f]{1,4} |       # 1-4 hex digits or",
     "(?(1)0 | () ) )           # if null previously matched, fail; else null",
     ":                         # followed by colon",
     "){1,7}                      # end item; 1-7 of them required               ",
     "[0-9a-f]{1,4} $             # final hex number at end of string",
     "(?(1)|.)                    # check that there was an empty component",
     "/xi",
     "a123::a123",
     "a123:b342::abcd",
     "a123:b342::324e:abcd",
     "a123:ddde:b342::324e:abcd",
     "a123:ddde:b342::324e:dcba:abcd",
     "a123:ddde:9999:b342::324e:dcba:abcd",
     "*** Failers",
     "1:2:3:4:5:6:7:8",
     "a123:bce:ddde:9999:b342::324e:dcba:abcd",
     "a123::9999:b342::324e:dcba:abcd",
     "abcde:2:3:4:5:6:7:8",
     "::1",
     "abcd:fee0:123::   ",
     ":1",
     "1:  "]
    [Just [" 0: a123::a123"],
     Just [" 1: "],
     Just [" 0: a123:b342::abcd"],
     Just [" 1: "],
     Just [" 0: a123:b342::324e:abcd"],
     Just [" 1: "],
     Just [" 0: a123:ddde:b342::324e:abcd"],
     Just [" 1: "],
     Just [" 0: a123:ddde:b342::324e:dcba:abcd"],
     Just [" 1: "],
     Just [" 0: a123:ddde:9999:b342::324e:dcba:abcd"],
     Just [" 1: "],
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing,
     Nothing]
,


testRegex "[z\\Qa-d]\\E]" []
    ["z",
     "a",
     "-",
     "d",
     "] ",
     "*** Failers",
     "b     "]
    [Just [" 0: z"],
     Just [" 0: a"],
     Just [" 0: -"],
     Just [" 0: d"],
     Just [" 0: ]"],
     Just [" 0: a"],
     Nothing]
,


testRegex "[\\z\\C]" []
    ["z",
     "C ",
     "",
     "/\\M/",
     "M ",
     "",
     "/(a+)*b/",
     "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ",
     "",
     "/(?i)reg(?:ul(?:[a\228]|ae)r|ex)/",
     "REGular",
     "regulaer",
     "Regex  ",
     "regul\228r "]
    [Just [" 0: z"],
     Just [" 0: C"],
     Just ["/\\M/"],
     Just [" 0: M"],
     Just ["/(a+)*b/"],
     Nothing,
     Just ["/(?i)reg(?:ul(?:[a\228]|ae)r|ex)/"],
     Just [" 0: REGular"],
     Just [" 0: regulaer"],
     Just [" 0: Regex"],
     Just [" 0: regul\\xe4r"]]
,


testRegex "\197\230\229\228[\224-\255\192-\223]+" []
    ["\197\230\229\228\224",
     "\197\230\229\228\255",
     "\197\230\229\228\192",
     "\197\230\229\228\223"]
    [Just [" 0: \\xc5\\xe6\\xe5\\xe4\\xe0"],
     Just [" 0: \\xc5\\xe6\\xe5\\xe4\\xff"],
     Just [" 0: \\xc5\\xe6\\xe5\\xe4\\xc0"],
     Just [" 0: \\xc5\\xe6\\xe5\\xe4\\xdf"]]
,


testRegex "(?<=Z)X." []
    ["\\x84XAZXB"]
    [Just [" 0: XB"]]
,


testRegex "ab cd (?x) de fg" []
    ["ab cd defg"]
    [Just [" 0: ab cd defg"]]
,


testRegex "ab cd(?x) de fg" []
    ["ab cddefg",
     "** Failers ",
     "abcddefg"]
    [Just [" 0: ab cddefg"],
     Nothing,
     Nothing]
,


testRegex "(?<![^f]oo)(bar)" []
    ["foobarX ",
     "** Failers ",
     "boobarX"]
    [Just [" 0: bar"],
     Just [" 1: bar"],
     Nothing,
     Nothing]
,


testRegex "(?<![^f])X" []
    ["offX",
     "** Failers",
     "onyX  "]
    [Just [" 0: X"],
     Nothing,
     Nothing]
,


testRegex "(?<=[^f])X" []
    ["onyX",
     "** Failers",
     "offX "]
    [Just [" 0: X"],
     Nothing,
     Nothing]
,


testRegex "^" [ERROR]
    ["a\\nb\\nc\\n",
     "\\ ",
     "",
     "/(?<=C\\n)^/mg",
     "A\\nC\\nC\\n "]
    [Just [" 0: "],
     Just [" 0: "],
     Just [" 0: "],
     Just [" 0: "],
     Just ["/(?<=C\\n)^/mg"],
     Just [" 0: "]]
,


testRegex "(?:(?(1)a|b)(X))+" []
    ["bXaX"]
    [Just [" 0: bXaX"],
     Just [" 1: X"]]
,


testRegex "(?:(?(1)\\1a|b)(X|Y))+" []
    ["bXXaYYaY",
     "bXYaXXaX  "]
    [Just [" 0: bXXaYYaY"],
     Just [" 1: Y"],
     Just [" 0: bX"],
     Just [" 1: X"]]
,


testRegex "()()()()()()()()()(?:(?(10)\\10a|b)(X|Y))+" []
    ["bXXaYYaY"]
    [Just [" 0: bX"],
     Just [" 1: "],
     Just [" 2: "],
     Just [" 3: "],
     Just [" 4: "],
     Just [" 5: "],
     Just [" 6: "],
     Just [" 7: "],
     Just [" 8: "],
     Just [" 9: "],
     Just ["10: X"]]
,


testRegex "[[,abc,]+]" []
    ["abc]",
     "a,b]",
     "[a,b,c]  "]
    [Just [" 0: abc]"],
     Just [" 0: a,b]"],
     Just [" 0: [a,b,c]"]]
,


testRegex "(?-x: )" [ERROR]
    ["A\\x20B",
     "",
     "\"(?x)(?-x: \\s*#\\s*)\"",
     "A # B",
     "** Failers",
     "#  "]
    [Just [" 0:  "],
     Just ["\"(?x)(?-x: \\s*#\\s*)\""],
     Just [" 0:  # "],
     Nothing,
     Nothing]
,


testRegex "(?x-is)(?:(?-ixs) \\s*#\\s*) include" [ERROR]
    ["A #include",
     "** Failers",
     "A#include  ",
     "A #Include"]
    [Just [" 0:  #include"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "a*b*\\w" []
    ["aaabbbb",
     "aaaa",
     "a"]
    [Just [" 0: aaabbbb"],
     Just [" 0: aaaa"],
     Just [" 0: a"]]
,


testRegex "a*b?\\w" []
    ["aaabbbb",
     "aaaa",
     "a"]
    [Just [" 0: aaabb"],
     Just [" 0: aaaa"],
     Just [" 0: a"]]
,


testRegex "a*b{0,4}\\w" []
    ["aaabbbb",
     "aaaa",
     "a"]
    [Just [" 0: aaabbbb"],
     Just [" 0: aaaa"],
     Just [" 0: a"]]
,


testRegex "a*b{0,}\\w" []
    ["aaabbbb",
     "aaaa",
     "a",
     "",
     "/a*\\d*\\w/",
     "0a",
     "a ",
     "",
     "/a*b *\\w/x",
     "a "]
    [Just [" 0: aaabbbb"],
     Just [" 0: aaaa"],
     Just [" 0: a"],
     Just ["/a*\\d*\\w/"],
     Just [" 0: 0a"],
     Just [" 0: a"],
     Just ["/a*b *\\w/x"],
     Just [" 0: a"]]
,


testRegex "ERROR" []
    ["*\\w/x",
     "a "]
    [Just [" 0: a"]]
,


testRegex "a* b *\\w" [ERROR]
    ["a "]
    [Just [" 0: a"]]
,


testRegex "^\\w+=.*(\\\\\\n.*)*" []
    ["abc=xyz\\\\\\npqr"]
    [Just [" 0: abc=xyz\\"]]
,


testRegex "(?=(\\w+))\\1:" []
    ["abcd:"]
    [Just [" 0: abcd:"],
     Just [" 1: abcd"]]
,


testRegex "^(?=(\\w+))\\1:" []
    ["abcd:"]
    [Just [" 0: abcd:"],
     Just [" 1: abcd"]]
,


testRegex "^\\Eabc" []
    ["abc",
     "",
     "/^[\\Eabc]/",
     "a",
     "** Failers ",
     "E ",
     "",
     "/^[a-\\Ec]/",
     "b",
     "** Failers",
     "-",
     "E    "]
    [Just [" 0: abc"],
     Just ["/^[\\Eabc]/"],
     Just [" 0: a"],
     Nothing,
     Nothing,
     Just ["/^[a-\\Ec]/"],
     Just [" 0: b"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^[a\\E\\E-\\Ec]" []
    ["b",
     "** Failers",
     "-",
     "E    "]
    [Just [" 0: b"],
     Nothing,
     Nothing,
     Nothing]
,


testRegex "^[\\E\\Qa\\E-\\Qz\\E]+" []
    ["b",
     "** Failers",
     "-  ",
     "",
     "/^[a\\Q]bc\\E]/",
     "a",
     "]",
     "c",
     "",
     "/^[a-\\Q\\E]/",
     "a",
     "-     "]
    [Just [" 0: b"],
     Nothing,
     Nothing,
     Just ["/^[a\\Q]bc\\E]/"],
     Just [" 0: a"],
     Just [" 0: ]"],
     Just [" 0: c"],
     Just ["/^[a-\\Q\\E]/"],
     Just [" 0: a"],
     Just [" 0: -"]]
,






testRegex "(a){0,3}(?(1)b|(c|))*D" []
    ["abbD",
     "ccccD",
     "D  "]
    [Just [" 0: abbD"],
     Just [" 1: a"],
     Just [" 0: ccccD"],
     Just [" 1: <unset>"],
     Just [" 2: "],
     Just [" 0: D"],
     Just [" 1: <unset>"],
     Just [" 2: "]]
,


testRegex "(a|)*\\d" []
    ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
     "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4"]
    [Nothing,
     Just [" 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4"],
     Just [" 1: "]]
,


testRegex "(?>a|)*\\d" []
    ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
     "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4"]
    [Nothing,
     Just [" 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4"]]
,






testRegex "( (A | (?(1)0|) )*   )" [ERROR]
    ["abcd"]
    [Just [" 0: "],
     Just [" 1: "],
     Just [" 2: "]]
,


testRegex "( ( (?(1)0|) )*   )" [ERROR]
    ["abcd"]
    [Just [" 0: "],
     Just [" 1: "],
     Just [" 2: "]]
,


testRegex "(  (?(1)0|)*   )" [ERROR]
    ["abcd"]
    [Just [" 0: "],
     Just [" 1: "]]