+select * from test_regex('a(?
+ test_regex
+-----------------------------------
+ {0,REG_ULOOKAROUND,REG_UNONPOSIX}
+ {a}
+(2 rows)
+
+-- expectMatch 23.17 HP (?<=b)b bb b
+select * from test_regex('(?<=b)b', 'bb', 'HP');
+ test_regex
+-----------------------------------
+ {0,REG_ULOOKAROUND,REG_UNONPOSIX}
+ {b}
+(2 rows)
+
+-- expectNomatch 23.18 HP (?<=b)b b
+select * from test_regex('(?<=b)b', 'b', 'HP');
+ test_regex
+-----------------------------------
+ {0,REG_ULOOKAROUND,REG_UNONPOSIX}
+(1 row)
+
+-- doing 24 "non-greedy quantifiers"
+-- expectMatch 24.1 PT ab+? abb ab
+select * from test_regex('ab+?', 'abb', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {ab}
+(2 rows)
+
+-- expectMatch 24.2 PT ab+?c abbc abbc
+select * from test_regex('ab+?c', 'abbc', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {abbc}
+(2 rows)
+
+-- expectMatch 24.3 PT ab*? abb a
+select * from test_regex('ab*?', 'abb', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {a}
+(2 rows)
+
+-- expectMatch 24.4 PT ab*?c abbc abbc
+select * from test_regex('ab*?c', 'abbc', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {abbc}
+(2 rows)
+
+-- expectMatch 24.5 PT ab?? ab a
+select * from test_regex('ab??', 'ab', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {a}
+(2 rows)
+
+-- expectMatch 24.6 PT ab??c abc abc
+select * from test_regex('ab??c', 'abc', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {abc}
+(2 rows)
+
+-- expectMatch 24.7 PQT "ab{2,4}?" abbbb abb
+select * from test_regex('ab{2,4}?', 'abbbb', 'PQT');
+ test_regex
+---------------------------------------------
+ {0,REG_UBOUNDS,REG_UNONPOSIX,REG_USHORTEST}
+ {abb}
+(2 rows)
+
+-- expectMatch 24.8 PQT "ab{2,4}?c" abbbbc abbbbc
+select * from test_regex('ab{2,4}?c', 'abbbbc', 'PQT');
+ test_regex
+---------------------------------------------
+ {0,REG_UBOUNDS,REG_UNONPOSIX,REG_USHORTEST}
+ {abbbbc}
+(2 rows)
+
+-- expectMatch 24.9 - 3z* 123zzzz456 3zzzz
+select * from test_regex('3z*', '123zzzz456', '-');
+ test_regex
+------------
+ {0}
+ {3zzzz}
+(2 rows)
+
+-- expectMatch 24.10 PT 3z*? 123zzzz456 3
+select * from test_regex('3z*?', '123zzzz456', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {3}
+(2 rows)
+
+-- expectMatch 24.11 - z*4 123zzzz456 zzzz4
+select * from test_regex('z*4', '123zzzz456', '-');
+ test_regex
+------------
+ {0}
+ {zzzz4}
+(2 rows)
+
+-- expectMatch 24.12 PT z*?4 123zzzz456 zzzz4
+select * from test_regex('z*?4', '123zzzz456', 'PT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {zzzz4}
+(2 rows)
+
+-- expectMatch 24.13 PT {^([^/]+?)(?:/([^/]+?))(?:/([^/]+?))?$} {foo/bar/baz} {foo/bar/baz} {foo} {bar} {baz}
+select * from test_regex('^([^/]+?)(?:/([^/]+?))(?:/([^/]+?))?$', 'foo/bar/baz', 'PT');
+ test_regex
+---------------------------------
+ {3,REG_UNONPOSIX,REG_USHORTEST}
+ {foo/bar/baz,foo,bar,baz}
+(2 rows)
+
+-- doing 25 "mixed quantifiers"
+-- # this is very incomplete as yet
+-- # should include |
+-- expectMatch 25.1 PNT {^(.*?)(a*)$} "xyza" xyza xyz a
+select * from test_regex('^(.*?)(a*)$', 'xyza', 'PNT');
+ test_regex
+-------------------------------------------------
+ {2,REG_UNONPOSIX,REG_UEMPTYMATCH,REG_USHORTEST}
+ {xyza,xyz,a}
+(2 rows)
+
+-- expectMatch 25.2 PNT {^(.*?)(a*)$} "xyzaa" xyzaa xyz aa
+select * from test_regex('^(.*?)(a*)$', 'xyzaa', 'PNT');
+ test_regex
+-------------------------------------------------
+ {2,REG_UNONPOSIX,REG_UEMPTYMATCH,REG_USHORTEST}
+ {xyzaa,xyz,aa}
+(2 rows)
+
+-- expectMatch 25.3 PNT {^(.*?)(a*)$} "xyz" xyz xyz ""
+select * from test_regex('^(.*?)(a*)$', 'xyz', 'PNT');
+ test_regex
+-------------------------------------------------
+ {2,REG_UNONPOSIX,REG_UEMPTYMATCH,REG_USHORTEST}
+ {xyz,xyz,""}
+(2 rows)
+
+-- doing 26 "tricky cases"
+-- # attempts to trick the matcher into accepting a short match
+-- expectMatch 26.1 - (week|wee)(night|knights) \
+-- "weeknights" weeknights wee knights
+select * from test_regex('(week|wee)(night|knights)', 'weeknights', '-');
+ test_regex
+--------------------------
+ {2}
+ {weeknights,wee,knights}
+(2 rows)
+
+-- expectMatch 26.2 RP {a(bc*).*\1} abccbccb abccbccb b
+select * from test_regex('a(bc*).*\1', 'abccbccb', 'RP');
+ test_regex
+--------------------------------
+ {1,REG_UBACKREF,REG_UNONPOSIX}
+ {abccbccb,b}
+(2 rows)
+
+-- expectMatch 26.3 - {a(b.[bc]*)+} abcbd abcbd bd
+select * from test_regex('a(b.[bc]*)+', 'abcbd', '-');
+ test_regex
+------------
+ {1}
+ {abcbd,bd}
+(2 rows)
+
+-- doing 27 "implementation misc."
+-- # duplicate arcs are suppressed
+-- expectMatch 27.1 P a(?:b|b)c abc abc
+select * from test_regex('a(?:b|b)c', 'abc', 'P');
+ test_regex
+-------------------
+ {0,REG_UNONPOSIX}
+ {abc}
+(2 rows)
+
+-- # make color/subcolor relationship go back and forth
+-- expectMatch 27.2 & {[ab][ab][ab]} aba aba
+select * from test_regex('[ab][ab][ab]', 'aba', '');
+ test_regex
+------------
+ {0}
+ {aba}
+(2 rows)
+
+select * from test_regex('[ab][ab][ab]', 'aba', 'b');
+ test_regex
+------------
+ {0}
+ {aba}
+(2 rows)
+
+-- expectMatch 27.3 & {[ab][ab][ab][ab][ab][ab][ab]} \
+-- "abababa" abababa
+select * from test_regex('[ab][ab][ab][ab][ab][ab][ab]', 'abababa', '');
+ test_regex
+------------
+ {0}
+ {abababa}
+(2 rows)
+
+select * from test_regex('[ab][ab][ab][ab][ab][ab][ab]', 'abababa', 'b');
+ test_regex
+------------
+ {0}
+ {abababa}
+(2 rows)
+
+-- doing 28 "boundary busters etc."
+-- # color-descriptor allocation changes at 10
+-- expectMatch 28.1 & abcdefghijkl "abcdefghijkl" abcdefghijkl
+select * from test_regex('abcdefghijkl', 'abcdefghijkl', '');
+ test_regex
+----------------
+ {0}
+ {abcdefghijkl}
+(2 rows)
+
+select * from test_regex('abcdefghijkl', 'abcdefghijkl', 'b');
+ test_regex
+----------------
+ {0}
+ {abcdefghijkl}
+(2 rows)
+
+-- # so does arc allocation
+-- expectMatch 28.2 P a(?:b|c|d|e|f|g|h|i|j|k|l|m)n "agn" agn
+select * from test_regex('a(?:b|c|d|e|f|g|h|i|j|k|l|m)n', 'agn', 'P');
+ test_regex
+-------------------
+ {0,REG_UNONPOSIX}
+ {agn}
+(2 rows)
+
+-- # subexpression tracking also at 10
+-- expectMatch 28.3 - a(((((((((((((b)))))))))))))c \
+-- "abc" abc b b b b b b b b b b b b b
+select * from test_regex('a(((((((((((((b)))))))))))))c', 'abc', '-');
+ test_regex
+---------------------------------
+ {13}
+ {abc,b,b,b,b,b,b,b,b,b,b,b,b,b}
+(2 rows)
+
+-- # state-set handling changes slightly at unsigned size (might be 64...)
+-- # (also stresses arc allocation)
+-- expectMatch 28.4 Q "ab{1,100}c" abbc abbc
+select * from test_regex('ab{1,100}c', 'abbc', 'Q');
+ test_regex
+-----------------
+ {0,REG_UBOUNDS}
+ {abbc}
+(2 rows)
+
+-- expectMatch 28.5 Q "ab{1,100}c" \
+-- "abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc" \
+-- abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
+select * from test_regex('ab{1,100}c', 'abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc', 'Q');
+ test_regex
+---------------------------------------
+ {0,REG_UBOUNDS}
+ {abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc}
+(2 rows)
+
+-- expectMatch 28.6 Q "ab{1,100}c" \
+-- "abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc"\
+-- abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
+select * from test_regex('ab{1,100}c', 'abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc', 'Q');
+ test_regex
+------------------------------------------------------------------------
+ {0,REG_UBOUNDS}
+ {abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc}
+(2 rows)
+
+-- # force small cache and bust it, several ways
+-- expectMatch 28.7 LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh
+select * from test_regex('\w+abcdefgh', 'xyzabcdefgh', 'LP');
+ test_regex
+-------------------------------
+ {0,REG_UNONPOSIX,REG_ULOCALE}
+ {xyzabcdefgh}
+(2 rows)
+
+-- expectMatch 28.8 %LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh
+select * from test_regex('\w+abcdefgh', 'xyzabcdefgh', '%LP');
+ test_regex
+-------------------------------
+ {0,REG_UNONPOSIX,REG_ULOCALE}
+ {xyzabcdefgh}
+(2 rows)
+
+-- expectMatch 28.9 %LP {\w+abcdefghijklmnopqrst} \
+-- "xyzabcdefghijklmnopqrst" xyzabcdefghijklmnopqrst
+select * from test_regex('\w+abcdefghijklmnopqrst', 'xyzabcdefghijklmnopqrst', '%LP');
+ test_regex
+-------------------------------
+ {0,REG_UNONPOSIX,REG_ULOCALE}
+ {xyzabcdefghijklmnopqrst}
+(2 rows)
+
+-- expectIndices 28.10 %LP {\w+(abcdefgh)?} xyz {0 2} {-1 -1}
+select * from test_regex('\w+(abcdefgh)?', 'xyz', '0%LP');
+ test_regex
+-------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE}
+ {"0 2","-1 -1"}
+(2 rows)
+
+-- expectIndices 28.11 %LP {\w+(abcdefgh)?} xyzabcdefg {0 9} {-1 -1}
+select * from test_regex('\w+(abcdefgh)?', 'xyzabcdefg', '0%LP');
+ test_regex
+-------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE}
+ {"0 9","-1 -1"}
+(2 rows)
+
+-- expectIndices 28.12 %LP {\w+(abcdefghijklmnopqrst)?} \
+-- "xyzabcdefghijklmnopqrs" {0 21} {-1 -1}
+select * from test_regex('\w+(abcdefghijklmnopqrst)?', 'xyzabcdefghijklmnopqrs', '0%LP');
+ test_regex
+-------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE}
+ {"0 21","-1 -1"}
+(2 rows)
+
+-- doing 29 "incomplete matches"
+-- expectPartial 29.1 t def abc {3 2} ""
+select * from test_regex('def', 'abc', '0!t');
+ test_regex
+---------------
+ {0}
+ {"3 2","3 2"}
+(2 rows)
+
+-- expectPartial 29.2 t bcd abc {1 2} ""
+select * from test_regex('bcd', 'abc', '0!t');
+ test_regex
+---------------
+ {0}
+ {"1 2","1 2"}
+(2 rows)
+
+-- expectPartial 29.3 t abc abab {0 3} ""
+select * from test_regex('abc', 'abab', '0!t');
+ test_regex
+---------------
+ {0}
+ {"0 3","0 3"}
+(2 rows)
+
+-- expectPartial 29.4 t abc abdab {3 4} ""
+select * from test_regex('abc', 'abdab', '0!t');
+ test_regex
+---------------
+ {0}
+ {"3 4","3 4"}
+(2 rows)
+
+-- expectIndices 29.5 t abc abc {0 2} {0 2}
+select * from test_regex('abc', 'abc', '0t');
+ test_regex
+---------------
+ {0}
+ {"0 2","0 2"}
+(2 rows)
+
+-- expectIndices 29.6 t abc xyabc {2 4} {2 4}
+select * from test_regex('abc', 'xyabc', '0t');
+ test_regex
+---------------
+ {0}
+ {"2 4","2 4"}
+(2 rows)
+
+-- expectPartial 29.7 t abc+ xyab {2 3} ""
+select * from test_regex('abc+', 'xyab', '0!t');
+ test_regex
+---------------
+ {0}
+ {"2 3","2 3"}
+(2 rows)
+
+-- expectIndices 29.8 t abc+ xyabc {2 4} {2 4}
+select * from test_regex('abc+', 'xyabc', '0t');
+ test_regex
+---------------
+ {0}
+ {"2 4","2 4"}
+(2 rows)
+
+-- knownBug expectIndices 29.9 t abc+ xyabcd {2 4} {6 5}
+select * from test_regex('abc+', 'xyabcd', '0t');
+ test_regex
+---------------
+ {0}
+ {"2 4","2 5"}
+(2 rows)
+
+-- expectIndices 29.10 t abc+ xyabcdd {2 4} {7 6}
+select * from test_regex('abc+', 'xyabcdd', '0t');
+ test_regex
+---------------
+ {0}
+ {"2 4","7 6"}
+(2 rows)
+
+-- expectPartial 29.11 tPT abc+? xyab {2 3} ""
+select * from test_regex('abc+?', 'xyab', '0!tPT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {"2 3","2 3"}
+(2 rows)
+
+-- # the retain numbers in these two may look wrong, but they aren't
+-- expectIndices 29.12 tPT abc+? xyabc {2 4} {5 4}
+select * from test_regex('abc+?', 'xyabc', '0tPT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {"2 4","5 4"}
+(2 rows)
+
+-- expectIndices 29.13 tPT abc+? xyabcc {2 4} {6 5}
+select * from test_regex('abc+?', 'xyabcc', '0tPT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {"2 4","6 5"}
+(2 rows)
+
+-- expectIndices 29.14 tPT abc+? xyabcd {2 4} {6 5}
+select * from test_regex('abc+?', 'xyabcd', '0tPT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {"2 4","6 5"}
+(2 rows)
+
+-- expectIndices 29.15 tPT abc+? xyabcdd {2 4} {7 6}
+select * from test_regex('abc+?', 'xyabcdd', '0tPT');
+ test_regex
+---------------------------------
+ {0,REG_UNONPOSIX,REG_USHORTEST}
+ {"2 4","7 6"}
+(2 rows)
+
+-- expectIndices 29.16 t abcd|bc xyabc {3 4} {2 4}
+select * from test_regex('abcd|bc', 'xyabc', '0t');
+ test_regex
+---------------
+ {0}
+ {"3 4","2 4"}
+(2 rows)
+
+-- expectPartial 29.17 tn .*k "xx\nyyy" {3 5} ""
+select * from test_regex('.*k', E'xx\nyyy', '0!tn');
+ test_regex
+---------------
+ {0}
+ {"3 5","3 5"}
+(2 rows)
+
+-- doing 30 "misc. oddities and old bugs"
+-- expectError 30.1 & *** BADRPT
+select * from test_regex('***', '', '');
+ERROR: invalid regular expression: quantifier operand invalid
+select * from test_regex('***', '', 'b');
+ERROR: invalid regular expression: quantifier operand invalid
+-- expectMatch 30.2 N a?b* abb abb
+select * from test_regex('a?b*', 'abb', 'N');
+ test_regex
+---------------------
+ {0,REG_UEMPTYMATCH}
+ {abb}
+(2 rows)
+
+-- expectMatch 30.3 N a?b* bb bb
+select * from test_regex('a?b*', 'bb', 'N');
+ test_regex
+---------------------
+ {0,REG_UEMPTYMATCH}
+ {bb}
+(2 rows)
+
+-- expectMatch 30.4 & a*b aab aab
+select * from test_regex('a*b', 'aab', '');
+ test_regex
+------------
+ {0}
+ {aab}
+(2 rows)
+
+select * from test_regex('a*b', 'aab', 'b');
+ test_regex
+------------
+ {0}
+ {aab}
+(2 rows)
+
+-- expectMatch 30.5 & ^a*b aaaab aaaab
+select * from test_regex('^a*b', 'aaaab', '');
+ test_regex
+------------
+ {0}
+ {aaaab}
+(2 rows)
+
+select * from test_regex('^a*b', 'aaaab', 'b');
+ test_regex
+------------
+ {0}
+ {aaaab}
+(2 rows)
+
+-- expectMatch 30.6 &M {[0-6][1-2][0-3][0-6][1-6][0-6]} \
+-- "010010" 010010
+select * from test_regex('[0-6][1-2][0-3][0-6][1-6][0-6]', '010010', 'M');
+ test_regex
+-----------------
+ {0,REG_UUNPORT}
+ {010010}
+(2 rows)
+
+select * from test_regex('[0-6][1-2][0-3][0-6][1-6][0-6]', '010010', 'Mb');
+ test_regex
+-----------------
+ {0,REG_UUNPORT}
+ {010010}
+(2 rows)
+
+-- # temporary REG_BOSONLY kludge
+-- expectMatch 30.7 s abc abcd abc
+select * from test_regex('abc', 'abcd', 's');
+ test_regex
+------------
+ {0}
+ {abc}
+(2 rows)
+
+-- expectNomatch 30.8 s abc xabcd
+select * from test_regex('abc', 'xabcd', 's');
+ test_regex
+------------
+ {0}
+(1 row)
+
+-- # back to normal stuff
+-- expectMatch 30.9 HLP {(?n)^(?![t#])\S+} \
+-- "tk\n\n#\n#\nit0" it0
+select * from test_regex('(?n)^(?![t#])\S+', E'tk\n\n#\n#\nit0', 'HLP');
+ test_regex
+-----------------------------------------------
+ {0,REG_ULOOKAROUND,REG_UNONPOSIX,REG_ULOCALE}
+ {it0}
+(2 rows)
+
+-- # Now for tests *not* written by Henry Spencer
+-- # Tests resulting from bugs reported by users
+-- test reg-31.1 {[[:xdigit:]] behaves correctly when followed by [[:space:]]} {
+-- set str {2:::DebugWin32}
+-- set re {([[:xdigit:]])([[:space:]]*)}
+-- list [regexp $re $str match xdigit spaces] $match $xdigit $spaces
+-- # Code used to produce {1 2:::DebugWin32 2 :::DebugWin32} !!!
+-- } {1 2 2 {}}
+select * from test_regex('([[:xdigit:]])([[:space:]]*)', '2:::DebugWin32', 'L');
+ test_regex
+-----------------
+ {2,REG_ULOCALE}
+ {2,2,""}
+(2 rows)
+
+-- test reg-32.1 {canmatch functionality -- at end} testregexp {
+-- set pat {blah}
+-- set line "asd asd"
+-- # can match at the final d, if '%' follows
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 7}
+select * from test_regex('blah', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"7 6","7 6"}
+(2 rows)
+
+-- test reg-32.2 {canmatch functionality -- at end} testregexp {
+-- set pat {s%$}
+-- set line "asd asd"
+-- # can only match after the end of the string
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 7}
+select * from test_regex('s%$', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"7 6","7 6"}
+(2 rows)
+
+-- test reg-32.3 {canmatch functionality -- not last char} testregexp {
+-- set pat {[^d]%$}
+-- set line "asd asd"
+-- # can only match after the end of the string
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 7}
+select * from test_regex('[^d]%$', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"7 6","7 6"}
+(2 rows)
+
+-- test reg-32.3.1 {canmatch functionality -- no match} testregexp {
+-- set pat {\Zx}
+-- set line "asd asd"
+-- # can match the last char, if followed by x
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 -1}
+select * from test_regex('\Zx', 'asd asd', 'cIP');
+ test_regex
+-----------------------------------
+ {0,REG_UNONPOSIX,REG_UIMPOSSIBLE}
+ {"-1 -1","-1 -1"}
+(2 rows)
+
+-- test reg-32.4 {canmatch functionality -- last char} {knownBug testregexp} {
+-- set pat {.x}
+-- set line "asd asd"
+-- # can match the last char, if followed by x
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 6}
+select * from test_regex('.x', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"0 6","0 6"}
+(2 rows)
+
+-- test reg-32.4.1 {canmatch functionality -- last char} {knownBug testregexp} {
+-- set pat {.x$}
+-- set line "asd asd"
+-- # can match the last char, if followed by x
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 6}
+select * from test_regex('.x$', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"0 6","0 6"}
+(2 rows)
+
+-- test reg-32.5 {canmatch functionality -- last char} {knownBug testregexp} {
+-- set pat {.[^d]x$}
+-- set line "asd asd"
+-- # can match the last char, if followed by not-d and x.
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 6}
+select * from test_regex('.[^d]x$', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"0 6","0 6"}
+(2 rows)
+
+-- test reg-32.6 {canmatch functionality -- last char} {knownBug testregexp} {
+-- set pat {[^a]%[^\r\n]*$}
+-- set line "asd asd"
+-- # can match at the final d, if '%' follows
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 6}
+select * from test_regex('[^a]%[^\r\n]*$', 'asd asd', 'cEP');
+ test_regex
+----------------------------
+ {0,REG_UBBS,REG_UNONPOSIX}
+ {"5 6","5 6"}
+(2 rows)
+
+-- test reg-32.7 {canmatch functionality -- last char} {knownBug testregexp} {
+-- set pat {[^a]%$}
+-- set line "asd asd"
+-- # can match at the final d, if '%' follows
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 6}
+select * from test_regex('[^a]%$', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"5 6","5 6"}
+(2 rows)
+
+-- test reg-32.8 {canmatch functionality -- last char} {knownBug testregexp} {
+-- set pat {[^x]%$}
+-- set line "asd asd"
+-- # can match at the final d, if '%' follows
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 6}
+select * from test_regex('[^x]%$', 'asd asd', 'c');
+ test_regex
+---------------
+ {0}
+ {"0 6","0 6"}
+(2 rows)
+
+-- test reg-32.9 {canmatch functionality -- more complex case} {knownBug testregexp} {
+-- set pat {((\B\B|\Bh+line)[ \t]*|[^\B]%[^\r\n]*)$}
+-- set line "asd asd"
+-- # can match at the final d, if '%' follows
+-- set res [testregexp -xflags -- c $pat $line resvar]
+-- lappend res $resvar
+-- } {0 6}
+select * from test_regex('((\B\B|\Bh+line)[ \t]*|[^\B]%[^\r\n]*)$', 'asd asd', 'cEP');
+ test_regex
+-------------------------------
+ {2,REG_UBBS,REG_UNONPOSIX}
+ {"0 6","-1 -1","-1 -1","0 6"}
+(2 rows)
+
+-- # Tests reg-33.*: Checks for bug fixes
+-- test reg-33.1 {Bug 230589} {
+-- regexp {[ ]*(^|[^%])%V} "*%V2" m s
+-- } 1
+select * from test_regex('[ ]*(^|[^%])%V', '*%V2', '-');
+ test_regex
+------------
+ {1}
+ {*%V,*}
+(2 rows)
+
+-- test reg-33.2 {Bug 504785} {
+-- regexp -inline {([^_.]*)([^.]*)\.(..)(.).*} bbcos_001_c01.q1la
+-- } {bbcos_001_c01.q1la bbcos _001_c01 q1 l}
+select * from test_regex('([^_.]*)([^.]*)\.(..)(.).*', 'bbcos_001_c01.q1la', '-');
+ test_regex
+------------------------------------------
+ {4}
+ {bbcos_001_c01.q1la,bbcos,_001_c01,q1,l}
+(2 rows)
+
+-- test reg-33.3 {Bug 505048} {
+-- regexp {\A\s*[^<]*\s*<([^>]+)>} a
+-- } 1
+select * from test_regex('\A\s*[^<]*\s*<([^>]+)>', 'a
', 'LP');
+ test_regex
+-------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE}
+(2 rows)
+
+-- test reg-33.4 {Bug 505048} {
+-- regexp {\A\s*([^b]*)b} ab
+-- } 1
+select * from test_regex('\A\s*([^b]*)b', 'ab', 'LP');
+ test_regex
+-------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE}
+ {ab,a}
+(2 rows)
+
+-- test reg-33.5 {Bug 505048} {
+-- regexp {\A\s*[^b]*(b)} ab
+-- } 1
+select * from test_regex('\A\s*[^b]*(b)', 'ab', 'LP');
+ test_regex
+-------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE}
+ {ab,b}
+(2 rows)
+
+-- test reg-33.6 {Bug 505048} {
+-- regexp {\A(\s*)[^b]*(b)} ab
+-- } 1
+select * from test_regex('\A(\s*)[^b]*(b)', 'ab', 'LP');
+ test_regex
+-------------------------------
+ {2,REG_UNONPOSIX,REG_ULOCALE}
+ {ab,"",b}
+(2 rows)
+
+-- test reg-33.7 {Bug 505048} {
+-- regexp {\A\s*[^b]*b} ab
+-- } 1
+select * from test_regex('\A\s*[^b]*b', 'ab', 'LP');
+ test_regex
+-------------------------------
+ {0,REG_UNONPOSIX,REG_ULOCALE}
+ {ab}
+(2 rows)
+
+-- test reg-33.8 {Bug 505048} {
+-- regexp -inline {\A\s*[^b]*b} ab
+-- } ab
+select * from test_regex('\A\s*[^b]*b', 'ab', 'LP');
+ test_regex
+-------------------------------
+ {0,REG_UNONPOSIX,REG_ULOCALE}
+ {ab}
+(2 rows)
+
+-- test reg-33.9 {Bug 505048} {
+-- regexp -indices -inline {\A\s*[^b]*b} ab
+-- } {{0 1}}
+select * from test_regex('\A\s*[^b]*b', 'ab', '0LP');
+ test_regex
+-------------------------------
+ {0,REG_UNONPOSIX,REG_ULOCALE}
+ {"0 1"}
+(2 rows)
+
+-- test reg-33.10 {Bug 840258} -body {
+-- regsub {(^|\n)+\.*b} \n.b {} tmp
+-- } -cleanup {
+-- unset tmp
+-- } -result 1
+select * from test_regex('(^|\n)+\.*b', E'\n.b', 'P');
+ test_regex
+-------------------
+ {1,REG_UNONPOSIX}
+ {" +
+ .b"," +
+ "}
+(2 rows)
+
+-- test reg-33.11 {Bug 840258} -body {
+-- regsub {(^|[\n\r]+)\.*\?<.*?(\n|\r)+} \
+-- "TQ\r\n.?<5000267>Test already stopped\r\n" {} tmp
+-- } -cleanup {
+-- unset tmp
+-- } -result 1
+select * from test_regex('(^|[\n\r]+)\.*\?<.*?(\n|\r)+', E'TQ\r\n.?<5000267>Test already stopped\r\n', 'EP');
+ test_regex
+-----------------------------------
+ {2,REG_UBBS,REG_UNONPOSIX}
+ {"\r +
+ .?<5000267>Test already stopped\r+
+ ","\r +
+ "," +
+ "}
+(2 rows)
+
+-- test reg-33.12 {Bug 1810264 - bad read} {
+-- regexp {\3161573148} {\3161573148}
+-- } 0
+select * from test_regex('\3161573148', '\3161573148', 'MP');
+ test_regex
+-------------------------------
+ {0,REG_UNONPOSIX,REG_UUNPORT}
+(1 row)
+
+-- test reg-33.13 {Bug 1810264 - infinite loop} {
+-- regexp {($|^)*} {x}
+-- } 1
+select * from test_regex('($|^)*', 'x', 'N');
+ test_regex
+---------------------
+ {1,REG_UEMPTYMATCH}
+ {"",""}
+(2 rows)
+
+-- # Some environments have small default stack sizes. [Bug 1905562]
+-- test reg-33.14 {Bug 1810264 - super-expensive expression} nonPortable {
+-- regexp {(x{200}){200}$y} {x}
+-- } 0
+-- This might or might not work depending on platform, so skip it
+-- select * from test_regex('(x{200}){200}$y', 'x', 'IQ');
+-- test reg-33.15.1 {Bug 3603557 - an "in the wild" RE} {
+-- lindex [regexp -expanded -about {
+-- ^TETRA_MODE_CMD # Message Type
+-- ([[:blank:]]+) # Pad
+-- (ETS_1_1|ETS_1_2|ETS_2_2) # SystemCode
+-- ([[:blank:]]+) # Pad
+-- (CONTINUOUS|CARRIER|MCCH|TRAFFIC) # SharingMode
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,2}) # ColourCode
+-- ([[:blank:]]+) # Pad
+-- (1|2|3|4|6|9|12|18) # TSReservedFrames
+-- ([[:blank:]]+) # Pad
+-- (PASS|TRUE|FAIL|FALSE) # UPlaneDTX
+-- ([[:blank:]]+) # Pad
+-- (PASS|TRUE|FAIL|FALSE) # Frame18Extension
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,4}) # MCC
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,5}) # MNC
+-- ([[:blank:]]+) # Pad
+-- (BOTH|BCAST|ENQRY|NONE) # NbrCellBcast
+-- ([[:blank:]]+) # Pad
+-- (UNKNOWN|LOW|MEDIUM|HIGH) # CellServiceLevel
+-- ([[:blank:]]+) # Pad
+-- (PASS|TRUE|FAIL|FALSE) # LateEntryInfo
+-- ([[:blank:]]+) # Pad
+-- (300|400) # FrequencyBand
+-- ([[:blank:]]+) # Pad
+-- (NORMAL|REVERSE) # ReverseOperation
+-- ([[:blank:]]+) # Pad
+-- (NONE|\+6\.25|\-6\.25|\+12\.5) # Offset
+-- ([[:blank:]]+) # Pad
+-- (10) # DuplexSpacing
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,4}) # MainCarrierNr
+-- ([[:blank:]]+) # Pad
+-- (0|1|2|3) # NrCSCCH
+-- ([[:blank:]]+) # Pad
+-- (15|20|25|30|35|40|45) # MSTxPwrMax
+-- ([[:blank:]]+) # Pad
+-- (\-125|\-120|\-115|\-110|\-105|\-100|\-95|\-90|\-85|\-80|\-75|\-70|\-65|\-60|\-55|\-50)
+-- # RxLevAccessMin
+-- ([[:blank:]]+) # Pad
+-- (\-53|\-51|\-49|\-47|\-45|\-43|\-41|\-39|\-37|\-35|\-33|\-31|\-29|\-27|\-25|\-23)
+-- # AccessParameter
+-- ([[:blank:]]+) # Pad
+-- (DISABLE|[[:digit:]]{3,4}) # RadioDLTimeout
+-- ([[:blank:]]+) # Pad
+-- (\-[[:digit:]]{2,3}) # RSSIThreshold
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,5}) # CCKIdSCKVerNr
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,5}) # LocationArea
+-- ([[:blank:]]+) # Pad
+-- ([(1|0)]{16}) # SubscriberClass
+-- ([[:blank:]]+) # Pad
+-- ([(1|0)]{12}) # BSServiceDetails
+-- ([[:blank:]]+) # Pad
+-- (RANDOMIZE|IMMEDIATE|[[:digit:]]{1,2}) # IMM
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,2}) # WT
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,2}) # Nu
+-- ([[:blank:]]+) # Pad
+-- ([0-1]) # FrameLngFctr
+-- ([[:blank:]]+) # Pad
+-- ([[:digit:]]{1,2}) # TSPtr
+-- ([[:blank:]]+) # Pad
+-- ([0-7]) # MinPriority
+-- ([[:blank:]]+) # Pad
+-- (PASS|TRUE|FAIL|FALSE) # ExtdSrvcsEnabled
+-- ([[:blank:]]+) # Pad
+-- (.*) # ConditionalFields
+-- }] 0
+-- } 68
+select * from test_regex($$
+ ^TETRA_MODE_CMD # Message Type
+ ([[:blank:]]+) # Pad
+ (ETS_1_1|ETS_1_2|ETS_2_2) # SystemCode
+ ([[:blank:]]+) # Pad
+ (CONTINUOUS|CARRIER|MCCH|TRAFFIC) # SharingMode
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,2}) # ColourCode
+ ([[:blank:]]+) # Pad
+ (1|2|3|4|6|9|12|18) # TSReservedFrames
+ ([[:blank:]]+) # Pad
+ (PASS|TRUE|FAIL|FALSE) # UPlaneDTX
+ ([[:blank:]]+) # Pad
+ (PASS|TRUE|FAIL|FALSE) # Frame18Extension
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,4}) # MCC
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,5}) # MNC
+ ([[:blank:]]+) # Pad
+ (BOTH|BCAST|ENQRY|NONE) # NbrCellBcast
+ ([[:blank:]]+) # Pad
+ (UNKNOWN|LOW|MEDIUM|HIGH) # CellServiceLevel
+ ([[:blank:]]+) # Pad
+ (PASS|TRUE|FAIL|FALSE) # LateEntryInfo
+ ([[:blank:]]+) # Pad
+ (300|400) # FrequencyBand
+ ([[:blank:]]+) # Pad
+ (NORMAL|REVERSE) # ReverseOperation
+ ([[:blank:]]+) # Pad
+ (NONE|\+6\.25|\-6\.25|\+12\.5) # Offset
+ ([[:blank:]]+) # Pad
+ (10) # DuplexSpacing
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,4}) # MainCarrierNr
+ ([[:blank:]]+) # Pad
+ (0|1|2|3) # NrCSCCH
+ ([[:blank:]]+) # Pad
+ (15|20|25|30|35|40|45) # MSTxPwrMax
+ ([[:blank:]]+) # Pad
+ (\-125|\-120|\-115|\-110|\-105|\-100|\-95|\-90|\-85|\-80|\-75|\-70|\-65|\-60|\-55|\-50)
+ # RxLevAccessMin
+ ([[:blank:]]+) # Pad
+ (\-53|\-51|\-49|\-47|\-45|\-43|\-41|\-39|\-37|\-35|\-33|\-31|\-29|\-27|\-25|\-23)
+ # AccessParameter
+ ([[:blank:]]+) # Pad
+ (DISABLE|[[:digit:]]{3,4}) # RadioDLTimeout
+ ([[:blank:]]+) # Pad
+ (\-[[:digit:]]{2,3}) # RSSIThreshold
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,5}) # CCKIdSCKVerNr
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,5}) # LocationArea
+ ([[:blank:]]+) # Pad
+ ([(1|0)]{16}) # SubscriberClass
+ ([[:blank:]]+) # Pad
+ ([(1|0)]{12}) # BSServiceDetails
+ ([[:blank:]]+) # Pad
+ (RANDOMIZE|IMMEDIATE|[[:digit:]]{1,2}) # IMM
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,2}) # WT
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,2}) # Nu
+ ([[:blank:]]+) # Pad
+ ([0-1]) # FrameLngFctr
+ ([[:blank:]]+) # Pad
+ ([[:digit:]]{1,2}) # TSPtr
+ ([[:blank:]]+) # Pad
+ ([0-7]) # MinPriority
+ ([[:blank:]]+) # Pad
+ (PASS|TRUE|FAIL|FALSE) # ExtdSrvcsEnabled
+ ([[:blank:]]+) # Pad
+ (.*) # ConditionalFields
+ $$, '', 'xLMPQ');
+ test_regex
+--------------------------------------------------------
+ {68,REG_UBOUNDS,REG_UNONPOSIX,REG_UUNPORT,REG_ULOCALE}
+(1 row)
+
+-- test reg-33.16.1 {Bug [8d2c0da36d]- another "in the wild" RE} {
+-- lindex [regexp -about "^MRK:client1: =1339 14HKelly Talisman 10011000 (\[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]*) \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 8 0 8 0 0 0 77 77 1 1 2 0 11 { 1 3 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 13HC6 My Creator 2 3 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 31HC7 Slightly offensive name, huh 3 8 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 23HE-mail:
[email protected] 4 9 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 17Hcompface must die 5 10 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 3HAir 6 12 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 14HPGP public key 7 13 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1
[email protected] 8 30 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 12H2 text/plain 9 30 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 0 13H2 x-kom/basic 10 33 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 1H0 11 14 8 \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* \[0-9\]* 00000000 1 1H3 }\r?"] 0
+-- } 1
+select * from test_regex(E'^MRK:client1: =1339 14HKelly Talisman 10011000 ([0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]*) [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 8 0 8 0 0 0 77 77 1 1 2 0 11 { 1 3 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1 13HC6 My Creator 2 3 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1 31HC7 Slightly offensive name, huh 3 8 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1 23HE-mail:
[email protected] 4 9 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1 17Hcompface must die 5 10 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 0 3HAir 6 12 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1 14HPGP public key 7 13 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1
[email protected] 8 30 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 0 12H2 text/plain 9 30 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 0 13H2 x-kom/basic 10 33 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1 1H0 11 14 8 [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* [0-9]* 00000000 1 1H3 }\r?', '', 'BMS');
+ test_regex
+-----------------------------------------
+ {1,REG_UBRACES,REG_UUNSPEC,REG_UUNPORT}
+(1 row)
+
+-- test reg-33.15 {constraint fixes} {
+-- regexp {(^)+^} x
+-- } 1
+select * from test_regex('(^)+^', 'x', 'N');
+ test_regex
+---------------------
+ {1,REG_UEMPTYMATCH}
+ {"",""}
+(2 rows)
+
+-- test reg-33.16 {constraint fixes} {
+-- regexp {($^)+} x
+-- } 0
+select * from test_regex('($^)+', 'x', 'N');
+ test_regex
+---------------------
+ {1,REG_UEMPTYMATCH}
+(1 row)
+
+-- test reg-33.17 {constraint fixes} {
+-- regexp {(^$)*} x
+-- } 1
+select * from test_regex('(^$)*', 'x', 'N');
+ test_regex
+---------------------
+ {1,REG_UEMPTYMATCH}
+ {"",NULL}
+(2 rows)
+
+-- test reg-33.18 {constraint fixes} {
+-- regexp {(^(?!aa))+} {aa bb cc}
+-- } 0
+select * from test_regex('(^(?!aa))+', 'aa bb cc', 'HP');
+ test_regex
+-----------------------------------
+ {1,REG_ULOOKAROUND,REG_UNONPOSIX}
+(1 row)
+
+-- test reg-33.19 {constraint fixes} {
+-- regexp {(^(?!aa)(?!bb)(?!cc))+} {aa x}
+-- } 0
+select * from test_regex('(^(?!aa)(?!bb)(?!cc))+', 'aa x', 'HP');
+ test_regex
+-----------------------------------
+ {1,REG_ULOOKAROUND,REG_UNONPOSIX}
+(1 row)
+
+-- test reg-33.20 {constraint fixes} {
+-- regexp {(^(?!aa)(?!bb)(?!cc))+} {bb x}
+-- } 0
+select * from test_regex('(^(?!aa)(?!bb)(?!cc))+', 'bb x', 'HP');
+ test_regex
+-----------------------------------
+ {1,REG_ULOOKAROUND,REG_UNONPOSIX}
+(1 row)
+
+-- test reg-33.21 {constraint fixes} {
+-- regexp {(^(?!aa)(?!bb)(?!cc))+} {cc x}
+-- } 0
+select * from test_regex('(^(?!aa)(?!bb)(?!cc))+', 'cc x', 'HP');
+ test_regex
+-----------------------------------
+ {1,REG_ULOOKAROUND,REG_UNONPOSIX}
+(1 row)
+
+-- test reg-33.22 {constraint fixes} {
+-- regexp {(^(?!aa)(?!bb)(?!cc))+} {dd x}
+-- } 1
+select * from test_regex('(^(?!aa)(?!bb)(?!cc))+', 'dd x', 'HP');
+ test_regex
+-----------------------------------
+ {1,REG_ULOOKAROUND,REG_UNONPOSIX}
+ {"",""}
+(2 rows)
+
+-- test reg-33.23 {} {
+-- regexp {abcd(\m)+xyz} x
+-- } 0
+select * from test_regex('abcd(\m)+xyz', 'x', 'ILP');
+ test_regex
+-----------------------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE,REG_UIMPOSSIBLE}
+(1 row)
+
+-- test reg-33.24 {} {
+-- regexp {abcd(\m)+xyz} a
+-- } 0
+select * from test_regex('abcd(\m)+xyz', 'a', 'ILP');
+ test_regex
+-----------------------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE,REG_UIMPOSSIBLE}
+(1 row)
+
+-- test reg-33.25 {} {
+-- regexp {^abcd*(((((^(a c(e?d)a+|)+|)+|)+|)+|a)+|)} x
+-- } 0
+select * from test_regex('^abcd*(((((^(a c(e?d)a+|)+|)+|)+|)+|a)+|)', 'x', 'S');
+ test_regex
+-----------------
+ {7,REG_UUNSPEC}
+(1 row)
+
+-- test reg-33.26 {} {
+-- regexp {a^(^)bcd*xy(((((($a+|)+|)+|)+$|)+|)+|)^$} x
+-- } 0
+select * from test_regex('a^(^)bcd*xy(((((($a+|)+|)+|)+$|)+|)+|)^$', 'x', 'IS');
+ test_regex
+---------------------------------
+ {7,REG_UUNSPEC,REG_UIMPOSSIBLE}
+(1 row)
+
+-- test reg-33.27 {} {
+-- regexp {xyz(\Y\Y)+} x
+-- } 0
+select * from test_regex('xyz(\Y\Y)+', 'x', 'LP');
+ test_regex
+-------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE}
+(1 row)
+
+-- test reg-33.28 {} {
+-- regexp {x|(?:\M)+} x
+-- } 1
+select * from test_regex('x|(?:\M)+', 'x', 'LNP');
+ test_regex
+-----------------------------------------------
+ {0,REG_UNONPOSIX,REG_ULOCALE,REG_UEMPTYMATCH}
+ {x}
+(2 rows)
+
+-- test reg-33.29 {} {
+-- # This is near the limits of the RE engine
+-- regexp [string repeat x*y*z* 480] x
+-- } 1
+-- The runtime cost of this seems out of proportion to the value,
+-- so for Postgres purposes reduce the repeat to 200x
+select * from test_regex(repeat('x*y*z*', 200), 'x', 'N');
+ test_regex
+---------------------
+ {0,REG_UEMPTYMATCH}
+ {x}
+(2 rows)
+
+-- test reg-33.30 {Bug 1080042} {
+-- regexp {(\Y)+} foo
+-- } 1
+select * from test_regex('(\Y)+', 'foo', 'LNP');
+ test_regex
+-----------------------------------------------
+ {1,REG_UNONPOSIX,REG_ULOCALE,REG_UEMPTYMATCH}
+ {"",""}
+(2 rows)
+