# This set of tests checks the API, internals, and non-Perl stuff for UTF
# support, including Unicode properties. However, tests that give different
# results in 8-bit, 16-bit, and 32-bit modes are excluded (see tests 10 and
# 12).

#newline_default lf any anycrlf

# PCRE2 and Perl disagree about the characteristics of certain Unicode
# characters. For example, 061C was considered by Perl to be Arabic, though
# it was not listed as such in the Unicode Scripts.txt file for Unicode 8.
# However, it *is* in that file for Unicode 10, but when I came to re-check,
# Perl had changed in the meantime, with 5.026 not recognizing it as Arabic.

# 2066-2069 are graphic and printable according to Perl, though they are
# actually "isolate" control characters. That is why the following tests are
# here rather than in test 4.

/^[\p{Arabic}]/utf
    \x{061c}

/^[[:graph:]]+$/utf,ucp
\= Expect no match
    \x{61c}
    \x{2066}
    \x{2067}
    \x{2068}
    \x{2069}

/^[[:print:]]+$/utf,ucp
\= Expect no match
    \x{61c}
    \x{2066}
    \x{2067}
    \x{2068}
    \x{2069}

/^[[:^graph:]]+$/utf,ucp
    \x{09}\x{0a}\x{1D}\x{20}\x{85}\x{a0}\x{61c}\x{1680}
    \x{2028}\x{2029}\x{202f}\x{2065}\x{2066}\x{2067}\x{2068}\x{2069}

/^[[:^print:]]+$/utf,ucp
    \x{09}\x{1D}\x{85}\x{61c}\x{2028}\x{2029}\x{2065}\x{2066}\x{2067}
    \x{2068}\x{2069}

# Perl does not consider U+180e to be a space character. It is true that it
# does not appear in the Unicode PropList.txt file as such, but in many other
# sources it is listed as a space, and has been treated as such in PCRE for
# a long time.

/^>[[:blank:]]*/utf,ucp
    >\x{20}\x{a0}\x{1680}\x{180e}\x{2000}\x{202f}\x{9}\x{b}\x{2028}

/^A\s+Z/utf,ucp
    A\x{85}\x{180e}\x{2005}Z

/^A[\s]+Z/utf,ucp
    A\x{2005}Z
    A\x{85}\x{2005}Z

/^[[:graph:]]+$/utf,ucp
\= Expect no match
    \x{180e}

/^[[:print:]]+$/utf,ucp
    \x{180e}

/^[[:^graph:]]+$/utf,ucp
    \x{09}\x{0a}\x{1D}\x{20}\x{85}\x{a0}\x{61c}\x{1680}\x{180e}

/^[[:^print:]]+$/utf,ucp
\= Expect no match
    \x{180e}

# End of U+180E tests.

# ---------------------------------------------------------------------

# Use no_start_optimize because the first code unit is different in 8-bit from
# the wider modes.
/\65535/IB,utf,no_start_optimize

/\65536/IB,utf,no_start_optimize

/\x{110000}/IB,utf

/\o{4200000}/IB,utf

/\x{ffffffff}/utf

/\o{37777777777}/utf

/\x{100000000}/utf

/\o{77777777777}/utf

/\x{d800}/utf

/\o{154000}/utf

/\x{dfff}/utf

/\o{157777}/utf

/\x{d7ff}/utf

/\o{153777}/utf

/\x{e000}/utf

/\o{170000}/utf

/^\x{100}a\x{1234}/utf
    \x{100}a\x{1234}bcd

/\x{0041}\x{2262}\x{0391}\x{002e}/IB,utf
    \x{0041}\x{2262}\x{0391}\x{002e}

/.{3,5}X/IB,utf
    \x{212ab}\x{212ab}\x{212ab}\x{861}X

/.{3,5}?/IB,utf
    \x{212ab}\x{212ab}\x{212ab}\x{861}

/^[ab]/IB,utf
    bar
\= Expect no match
    c
    \x{ff}
    \x{100}

/\x{100}*(\d+|"(?1)")/utf
    1234
    "1234"
    \x{100}1234
    "\x{100}1234"
    \x{100}\x{100}12ab
    \x{100}\x{100}"12"
\= Expect no match
    \x{100}\x{100}abcd

/\x{100}*/IB,utf

/a\x{100}*/IB,utf

/ab\x{100}*/IB,utf

/[\x{200}-\x{100}]/utf

/[Ā-Ą]/utf
    \x{100}
    \x{104}
\= Expect no match
    \x{105}
    \x{ff}

/[\xFF]/IB
    >\xff<

/[^\xFF]/IB

/[Ä-Ü]/utf
    Ö # Matches without Study
    \x{d6}

/[Ä-Ü]/utf
    Ö <-- Same with Study
    \x{d6}

/[\x{c4}-\x{dc}]/utf
    Ö # Matches without Study
    \x{d6}

/[\x{c4}-\x{dc}]/utf
    Ö <-- Same with Study
    \x{d6}

/[^\x{100}]abc(xyz(?1))/IB,utf

/(\x{100}(b(?2)c))?/IB,utf

/(\x{100}(b(?2)c)){0,2}/IB,utf

/(\x{100}(b(?1)c))?/IB,utf

/(\x{100}(b(?1)c)){0,2}/IB,utf

/\W/utf
    A.B
    A\x{100}B

/\w/utf
    \x{100}X

# Use no_start_optimize because the first code unit is different in 8-bit from
# the wider modes.

/^\ሴ/IB,utf,no_start_optimize

/()()()()()()()()()()
 ()()()()()()()()()()
 ()()()()()()()()()()
 ()()()()()()()()()()
 A (x) (?41) B/x,utf
    AxxB

/^[\x{100}\E-\Q\E\x{150}]/B,utf

/^[\QĀ\E-\QŐ\E]/B,utf

/^abc./gmx,newline=any,utf
    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x{0085}abc7 \x{2028}abc8 \x{2029}abc9 JUNK

/abc.$/gmx,newline=any,utf
    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x{0085} abc7\x{2028} abc8\x{2029} abc9

/^a\Rb/bsr=unicode,utf
    a\nb
    a\rb
    a\r\nb
    a\x0bb
    a\x0cb
    a\x{85}b
    a\x{2028}b
    a\x{2029}b
\= Expect no match
    a\n\rb

/^a\R*b/bsr=unicode,utf
    ab
    a\nb
    a\rb
    a\r\nb
    a\x0bb
    a\x0c\x{2028}\x{2029}b
    a\x{85}b
    a\n\rb
    a\n\r\x{85}\x0cb

/^a\R+b/bsr=unicode,utf
    a\nb
    a\rb
    a\r\nb
    a\x0bb
    a\x0c\x{2028}\x{2029}b
    a\x{85}b
    a\n\rb
    a\n\r\x{85}\x0cb
\= Expect no match
    ab

/^a\R{1,3}b/bsr=unicode,utf
    a\nb
    a\n\rb
    a\n\r\x{85}b
    a\r\n\r\nb
    a\r\n\r\n\r\nb
    a\n\r\n\rb
    a\n\n\r\nb
\= Expect no match
    a\n\n\n\rb
    a\r

/\H\h\V\v/utf
    X X\x0a
    X\x09X\x0b
\= Expect no match
    \x{a0} X\x0a

/\H*\h+\V?\v{3,4}/utf
    \x09\x20\x{a0}X\x0a\x0b\x0c\x0d\x0a
    \x09\x20\x{a0}\x0a\x0b\x0c\x0d\x0a
    \x09\x20\x{a0}\x0a\x0b\x0c
\= Expect no match
    \x09\x20\x{a0}\x0a\x0b

/\H\h\V\v/utf
    \x{3001}\x{3000}\x{2030}\x{2028}
    X\x{180e}X\x{85}
\= Expect no match
    \x{2009} X\x0a

/\H*\h+\V?\v{3,4}/utf
    \x{1680}\x{180e}\x{2007}X\x{2028}\x{2029}\x0c\x0d\x0a
    \x09\x{205f}\x{a0}\x0a\x{2029}\x0c\x{2028}\x0a
    \x09\x20\x{202f}\x0a\x0b\x0c
\= Expect no match
    \x09\x{200a}\x{a0}\x{2028}\x0b

/[\h]/B,utf
    >\x{1680}

/[\h]{3,}/B,utf
    >\x{1680}\x{180e}\x{2000}\x{2003}\x{200a}\x{202f}\x{205f}\x{3000}<

/[\v]/B,utf

/[\H]/B,utf

/[\V]/B,utf

/.*$/newline=any,utf
    \x{1ec5}

/a\Rb/I,bsr=anycrlf,utf
    a\rb
    a\nb
    a\r\nb
\= Expect no match
    a\x{85}b
    a\x0bb

/a\Rb/I,bsr=unicode,utf
    a\rb
    a\nb
    a\r\nb
    a\x{85}b
    a\x0bb

/a\R?b/I,bsr=anycrlf,utf
    a\rb
    a\nb
    a\r\nb
\= Expect no match
    a\x{85}b
    a\x0bb

/a\R?b/I,bsr=unicode,utf
    a\rb
    a\nb
    a\r\nb
    a\x{85}b
    a\x0bb

/.*a.*=.b.*/utf,newline=any
    QQQ\x{2029}ABCaXYZ=!bPQR
\= Expect no match
    a\x{2029}b
    \x61\xe2\x80\xa9\x62

/[[:a\x{100}b:]]/utf

/[\p{InvalidOrBadProperty}]/

/a[^]b/utf,allow_empty_class,match_unset_backref
    a\x{1234}b
    a\nb
\= Expect no match
    ab

/a[^]+b/utf,allow_empty_class,match_unset_backref
    aXb
    a\nX\nX\x{1234}b
\= Expect no match
    ab

/(\x{de})\1/
    \x{de}\x{de}

/X/newline=any,utf,firstline
    A\x{1ec5}ABCXYZ

/Xa{2,4}b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/Xa{2,4}?b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/Xa{2,4}+b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/X\x{123}{2,4}b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X\x{123}{2,4}?b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X\x{123}{2,4}+b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X\x{123}{2,4}b/utf
\= Expect no match
    Xx\=ps
    X\x{123}x\=ps
    X\x{123}\x{123}x\=ps
    X\x{123}\x{123}\x{123}x\=ps
    X\x{123}\x{123}\x{123}\x{123}x\=ps

/X\x{123}{2,4}?b/utf
\= Expect no match
    Xx\=ps
    X\x{123}x\=ps
    X\x{123}\x{123}x\=ps
    X\x{123}\x{123}\x{123}x\=ps
    X\x{123}\x{123}\x{123}\x{123}x\=ps

/X\x{123}{2,4}+b/utf
\= Expect no match
    Xx\=ps
    X\x{123}x\=ps
    X\x{123}\x{123}x\=ps
    X\x{123}\x{123}\x{123}x\=ps
    X\x{123}\x{123}\x{123}\x{123}x\=ps

/X\d{2,4}b/utf
    X\=ps
    X3\=ps
    X33\=ps
    X333\=ps
    X3333\=ps

/X\d{2,4}?b/utf
    X\=ps
    X3\=ps
    X33\=ps
    X333\=ps
    X3333\=ps

/X\d{2,4}+b/utf
    X\=ps
    X3\=ps
    X33\=ps
    X333\=ps
    X3333\=ps

/X\D{2,4}b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/X\D{2,4}?b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/X\D{2,4}+b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/X\D{2,4}b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X\D{2,4}?b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X\D{2,4}+b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X[abc]{2,4}b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/X[abc]{2,4}?b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/X[abc]{2,4}+b/utf
    X\=ps
    Xa\=ps
    Xaa\=ps
    Xaaa\=ps
    Xaaaa\=ps

/X[abc\x{123}]{2,4}b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X[abc\x{123}]{2,4}?b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X[abc\x{123}]{2,4}+b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X[^a]{2,4}b/utf
    X\=ps
    Xz\=ps
    Xzz\=ps
    Xzzz\=ps
    Xzzzz\=ps

/X[^a]{2,4}?b/utf
    X\=ps
    Xz\=ps
    Xzz\=ps
    Xzzz\=ps
    Xzzzz\=ps

/X[^a]{2,4}+b/utf
    X\=ps
    Xz\=ps
    Xzz\=ps
    Xzzz\=ps
    Xzzzz\=ps

/X[^a]{2,4}b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X[^a]{2,4}?b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/X[^a]{2,4}+b/utf
    X\=ps
    X\x{123}\=ps
    X\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\=ps
    X\x{123}\x{123}\x{123}\x{123}\=ps

/(Y)X\1{2,4}b/utf
    YX\=ps
    YXY\=ps
    YXYY\=ps
    YXYYY\=ps
    YXYYYY\=ps

/(Y)X\1{2,4}?b/utf
    YX\=ps
    YXY\=ps
    YXYY\=ps
    YXYYY\=ps
    YXYYYY\=ps

/(Y)X\1{2,4}+b/utf
    YX\=ps
    YXY\=ps
    YXYY\=ps
    YXYYY\=ps
    YXYYYY\=ps

/(\x{123})X\1{2,4}b/utf
    \x{123}X\=ps
    \x{123}X\x{123}\=ps
    \x{123}X\x{123}\x{123}\=ps
    \x{123}X\x{123}\x{123}\x{123}\=ps
    \x{123}X\x{123}\x{123}\x{123}\x{123}\=ps

/(\x{123})X\1{2,4}?b/utf
    \x{123}X\=ps
    \x{123}X\x{123}\=ps
    \x{123}X\x{123}\x{123}\=ps
    \x{123}X\x{123}\x{123}\x{123}\=ps
    \x{123}X\x{123}\x{123}\x{123}\x{123}\=ps

/(\x{123})X\1{2,4}+b/utf
    \x{123}X\=ps
    \x{123}X\x{123}\=ps
    \x{123}X\x{123}\x{123}\=ps
    \x{123}X\x{123}\x{123}\x{123}\=ps
    \x{123}X\x{123}\x{123}\x{123}\x{123}\=ps

/\bthe cat\b/utf
    the cat\=ps
    the cat\=ph

/abcd*/utf
    xxxxabcd\=ps
    xxxxabcd\=ph

/abcd*/i,utf
    xxxxabcd\=ps
    xxxxabcd\=ph
    XXXXABCD\=ps
    XXXXABCD\=ph

/abc\d*/utf
    xxxxabc1\=ps
    xxxxabc1\=ph

/(a)bc\1*/utf
    xxxxabca\=ps
    xxxxabca\=ph

/abc[de]*/utf
    xxxxabcde\=ps
    xxxxabcde\=ph

/X\W{3}X/utf
    X\=ps

/\sxxx\s/utf,tables=2
    AB\x{85}xxx\x{a0}XYZ
    AB\x{a0}xxx\x{85}XYZ

/\S \S/utf,tables=2
    \x{a2} \x{84}

'A#хц'Bx,newline=any,utf

'A#хц
  PQ'Bx,newline=any,utf

/a+#хaa
  z#XX?/Bx,newline=any,utf

/a+#хaa
  z#х?/Bx,newline=any,utf

/\g{A}xxx#bXX(?'A'123)
(?'A'456)/Bx,newline=any,utf

/\g{A}xxx#bх(?'A'123)
(?'A'456)/Bx,newline=any,utf

/^\cģ/utf

/(\R*)(.)/s,utf
    \r\n
    \r\r\n\n\r
    \r\r\n\n\r\n

/(\R)*(.)/s,utf
    \r\n
    \r\r\n\n\r
    \r\r\n\n\r\n

/[^\x{1234}]+/Ii,utf

/[^\x{1234}]+?/Ii,utf

/[^\x{1234}]++/Ii,utf

/[^\x{1234}]{2}/Ii,utf

/f.*/
    for\=ph

/f.*/s
    for\=ph

/f.*/utf
    for\=ph

/f.*/s,utf
    for\=ph

/\x{d7ff}\x{e000}/utf

/\x{d800}/utf

/\x{dfff}/utf

/\h+/utf
    \x{1681}\x{200b}\x{1680}\x{2000}\x{202f}\x{3000}
    \x{3001}\x{2fff}\x{200a}\x{a0}\x{2000}

/[\h\x{e000}]+/B,utf
    \x{1681}\x{200b}\x{1680}\x{2000}\x{202f}\x{3000}
    \x{3001}\x{2fff}\x{200a}\x{a0}\x{2000}

/\H+/utf
    \x{1680}\x{180e}\x{167f}\x{1681}\x{180d}\x{180f}
    \x{2000}\x{200a}\x{1fff}\x{200b}
    \x{202f}\x{205f}\x{202e}\x{2030}\x{205e}\x{2060}
    \x{a0}\x{3000}\x{9f}\x{a1}\x{2fff}\x{3001}

/[\H\x{d7ff}]+/B,utf
    \x{1680}\x{180e}\x{167f}\x{1681}\x{180d}\x{180f}
    \x{2000}\x{200a}\x{1fff}\x{200b}
    \x{202f}\x{205f}\x{202e}\x{2030}\x{205e}\x{2060}
    \x{a0}\x{3000}\x{9f}\x{a1}\x{2fff}\x{3001}

/\v+/utf
    \x{2027}\x{2030}\x{2028}\x{2029}
    \x09\x0e\x{84}\x{86}\x{85}\x0a\x0b\x0c\x0d

/[\v\x{e000}]+/B,utf
    \x{2027}\x{2030}\x{2028}\x{2029}
    \x09\x0e\x{84}\x{86}\x{85}\x0a\x0b\x0c\x0d

/\V+/utf
    \x{2028}\x{2029}\x{2027}\x{2030}
    \x{85}\x0a\x0b\x0c\x0d\x09\x0e\x{84}\x{86}

/[\V\x{d7ff}]+/B,utf
    \x{2028}\x{2029}\x{2027}\x{2030}
    \x{85}\x0a\x0b\x0c\x0d\x09\x0e\x{84}\x{86}

/\R+/bsr=unicode,utf
    \x{2027}\x{2030}\x{2028}\x{2029}
    \x09\x0e\x{84}\x{86}\x{85}\x0a\x0b\x0c\x0d

/(..)\1/utf
    ab\=ps
    aba\=ps
    abab\=ps

/(..)\1/i,utf
    ab\=ps
    abA\=ps
    aBAb\=ps

/(..)\1{2,}/utf
    ab\=ps
    aba\=ps
    abab\=ps
    ababa\=ps
    ababab\=ps
    ababab\=ph
    abababa\=ps
    abababa\=ph

/(..)\1{2,}/i,utf
    ab\=ps
    aBa\=ps
    aBAb\=ps
    AbaBA\=ps
    abABAb\=ps
    aBAbaB\=ph
    abABabA\=ps
    abaBABa\=ph

/(..)\1{2,}?x/i,utf
    ab\=ps
    abA\=ps
    aBAb\=ps
    abaBA\=ps
    abAbaB\=ps
    abaBabA\=ps
    abAbABaBx\=ps

/./utf,newline=crlf
    \r\=ps
    \r\=ph

/.{2,3}/utf,newline=crlf
    \r\=ps
    \r\=ph
    \r\r\=ps
    \r\r\=ph
    \r\r\r\=ps
    \r\r\r\=ph

/.{2,3}?/utf,newline=crlf
    \r\=ps
    \r\=ph
    \r\r\=ps
    \r\r\=ph
    \r\r\r\=ps
    \r\r\r\=ph

/[^\x{100}][^\x{1234}][^\x{ffff}][^\x{10000}][^\x{10ffff}]/B,utf

/[^\x{100}][^\x{1234}][^\x{ffff}][^\x{10000}][^\x{10ffff}]/Bi,utf

/[^\x{100}]*[^\x{10000}]+[^\x{10ffff}]??[^\x{8000}]{4,}[^\x{7fff}]{2,9}?[^\x{fffff}]{5,6}+/B,utf

/[^\x{100}]*[^\x{10000}]+[^\x{10ffff}]??[^\x{8000}]{4,}[^\x{7fff}]{2,9}?[^\x{fffff}]{5,6}+/Bi,utf

/(?<=\x{1234}\x{1234})\bxy/I,utf

/(?<!^)ETA/utf
\= Expect no match
    ETA

/\u0100/B,utf,alt_bsux,allow_empty_class,match_unset_backref

/[\u0100-\u0200]/B,utf,alt_bsux,allow_empty_class,match_unset_backref

/\ud800/utf,alt_bsux,allow_empty_class,match_unset_backref

/^\u{0000000000010ffff}/utf,extra_alt_bsux
    \x{10ffff}

/\u{ 1bb1}/utf,extra_alt_bsux
    u{ 1bb1}
\= Expect no match
    \x{1bb1}

/\u/utf,alt_bsux
    \\u

/^a+[a\x{200}]/B,utf
    aa

/[b-d\x{200}-\x{250}]*[ae-h]?#[\x{200}-\x{250}]{0,8}[\x00-\xff]*#[\x{200}-\x{250}]+[a-z]/B,utf

/[\p{L}]/IB

/[\p{^L}]/IB

/[\P{L}]/IB

/[\P{^L}]/IB

/[abc\p{L}\x{0660}]/IB,utf

/[\p{Nd}]/IB,utf
    1234

/[\p{Nd}+-]+/IB,utf
    1234
    12-34
    12+\x{661}-34
\= Expect no match
    abcd

/(?:[\PPa*]*){8,}/

/[\P{Any}]/B

/[^\P{Any}\P{Any}]/B

/[\P{Any}\E]/B

/\p{Any}#\P{Any}![\p{Any}]:[\P{Any}]@[\p{Any}a-z]%[\P{Any}c]/B,utf

/[\P{Any}\P{Any}\P{Any}]![\p{Any}\p{Any}\p{Any}]:[^\P{Any}\P{Any}]@[^\p{Any}\p{Any}]%[^\p{Any}\P{Any}]/B,utf

/(\P{Yi}+\277)/

/(\P{Yi}+\277)?/

/(?<=\P{Yi}{3}A)X/

/\p{Yi}+(\P{Yi}+)(?1)/

/(\P{Yi}{2}\277)?/

/[\P{Yi}A]/

/[\P{Yi}\P{Yi}\P{Yi}A]/

/[^\P{Yi}A]/

/[^\P{Yi}\P{Yi}\P{Yi}A]/

/(\P{Yi}*\277)*/

/(\P{Yi}*?\277)*/

/(\p{Yi}*+\277)*/

/(\P{Yi}?\277)*/

/(\P{Yi}??\277)*/

/(\p{Yi}?+\277)*/

/(\P{Yi}{0,3}\277)*/

/(\P{Yi}{0,3}?\277)*/

/(\p{Yi}{0,3}+\277)*/

/\p{Zl}{2,3}+/B,utf
      
    \x{2028}\x{2028}\x{2028}

/\p{Zl}/B,utf

/\p{Lu}{3}+/B,utf

/\pL{2}+/B,utf

/\p{Cc}{2}+/B,utf

/^\p{Cf}/utf
    \x{180e}
    \x{061c}
    \x{2066}
    \x{2067}
    \x{2068}
    \x{2069}

/^\p{Cs}/utf
    \x{dfff}\=no_utf_check
\= Expect no match
    \x{09f}

/^\p{Mn}/utf
    \x{1a1b}

/^\p{Pe}/utf
    \x{2309}
    \x{230b}

/^\p{Ps}/utf
    \x{2308}
    \x{230a}

/^\p{Sc}+/utf
    $\x{a2}\x{a3}\x{a4}\x{a5}\x{a6}
    \x{9f2}
\= Expect no match
    X
    \x{2c2}

/^\p{Zs}/utf
    \ \
    \x{a0}
    \x{1680}
    \x{2000}
    \x{2001}
\= Expect no match
    \x{2028}
    \x{200d}

/[\x{c0}\x{391}]/i,utf
    \x{c0}
    \x{e0}

# The next two are special cases where the lengths of the different cases of
# the same character differ. The first went wrong with heap frame storage; the
# second was broken in all cases.

/^\x{023a}+?(\x{0130}+)/i,utf
  \x{023a}\x{2c65}\x{0130}

/^\x{023a}+([^X])/i,utf
  \x{023a}\x{2c65}X

/\x{c0}+\x{116}+/i,utf
    \x{c0}\x{e0}\x{116}\x{117}

/[\x{c0}\x{116}]+/i,utf
    \x{c0}\x{e0}\x{116}\x{117}

/(\x{de})\1/i,utf
    \x{de}\x{de}
    \x{de}\x{fe}
    \x{fe}\x{fe}
    \x{fe}\x{de}

/^\x{c0}$/i,utf
    \x{c0}
    \x{e0}

/^\x{e0}$/i,utf
    \x{c0}
    \x{e0}

# The next two should be Perl-compatible, but it fails to match \x{e0}. PCRE
# will match it only with UCP support, because without that it has no notion
# of case for anything other than the ASCII letters.

/((?i)[\x{c0}])/utf
    \x{c0}
    \x{e0}

/(?i:[\x{c0}])/utf
    \x{c0}
    \x{e0}

# These are PCRE's extra properties to help with Unicodizing \d etc.

/^\p{Xan}/utf
    ABCD
    1234
    \x{6ca}
    \x{a6c}
    \x{10a7}
\= Expect no match
    _ABC

/^\p{Xan}+/utf
    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
\= Expect no match
    _ABC

/^\p{Xan}+?/utf
    \x{6ca}\x{a6c}\x{10a7}_

/^\p{Xan}*/utf
    ABCD1234\x{6ca}\x{a6c}\x{10a7}_

/^\p{Xan}{2,9}/utf
    ABCD1234\x{6ca}\x{a6c}\x{10a7}_

/^\p{Xan}{2,9}?/utf
    \x{6ca}\x{a6c}\x{10a7}_

/^[\p{Xan}]/utf
    ABCD1234_
    1234abcd_
    \x{6ca}
    \x{a6c}
    \x{10a7}
\= Expect no match
    _ABC

/^[\p{Xan}]+/utf
    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
\= Expect no match
    _ABC

/^>\p{Xsp}/utf
    >\x{1680}\x{2028}\x{0b}
    >\x{a0}
\= Expect no match
    \x{0b}

/^>\p{Xsp}+/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>\p{Xsp}+?/utf
    >\x{1680}\x{2028}\x{0b}

/^>\p{Xsp}*/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>\p{Xsp}{2,9}/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>\p{Xsp}{2,9}?/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>[\p{Xsp}]/utf
    >\x{2028}\x{0b}

/^>[\p{Xsp}]+/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>\p{Xps}/utf
    >\x{1680}\x{2028}\x{0b}
    >\x{a0}
\= Expect no match
    \x{0b}

/^>\p{Xps}+/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>\p{Xps}+?/utf
    >\x{1680}\x{2028}\x{0b}

/^>\p{Xps}*/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>\p{Xps}{2,9}/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>\p{Xps}{2,9}?/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^>[\p{Xps}]/utf
    >\x{2028}\x{0b}

/^>[\p{Xps}]+/utf
    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}

/^\p{Xwd}/utf
    ABCD
    1234
    \x{6ca}
    \x{a6c}
    \x{10a7}
    _ABC
\= Expect no match
    []

/^\p{Xwd}+/utf
    ABCD1234\x{6ca}\x{a6c}\x{10a7}_

/^\p{Xwd}+?/utf
    \x{6ca}\x{a6c}\x{10a7}_

/^\p{Xwd}*/utf
    ABCD1234\x{6ca}\x{a6c}\x{10a7}_

/^\p{Xwd}{2,9}/utf
    A_B12\x{6ca}\x{a6c}\x{10a7}

/^\p{Xwd}{2,9}?/utf
    \x{6ca}\x{a6c}\x{10a7}_

/^[\p{Xwd}]/utf
    ABCD1234_
    1234abcd_
    \x{6ca}
    \x{a6c}
    \x{10a7}
    _ABC
\= Expect no match
    []

/^[\p{Xwd}]+/utf
    ABCD1234\x{6ca}\x{a6c}\x{10a7}_

# A check not in UTF-8 mode

/^[\p{Xwd}]+/
    ABCD1234_

# Some negative checks

/^[\P{Xwd}]+/utf
    !.+\x{019}\x{482}AB

/^[\p{^Xwd}]+/utf
    !.+\x{019}\x{589}AB

/[\D]/B,utf,ucp
    1\x{3c8}2

/[\d]/B,utf,ucp
    >\x{6f4}<

/[\S]/B,utf,ucp
    \x{1680}\x{6f4}\x{1680}

/[\s]/B,utf,ucp
    >\x{1680}<

/[\W]/B,utf,ucp
    A\x{1735}B

/[\w]/B,utf,ucp
    >\x{1723}<

/\D/B,utf,ucp
    1\x{3c8}2

/\d/B,utf,ucp
    >\x{6f4}<

/\S/B,utf,ucp
    \x{1680}\x{6f4}\x{1680}

/\s/B,utf,ucp
    >\x{1680}>

/\W/B,utf,ucp
    A\x{1735}B

/\w/B,utf,ucp
    >\x{1723}<

/[[:alpha:]]/B,ucp

/[[:lower:]]/B,ucp

/[[:upper:]]/B,ucp

/[[:alnum:]]/B,ucp

/[[:ascii:]]/B,ucp

/[[:cntrl:]]/B,ucp

/[[:digit:]]/B,ucp

/[[:digit:]]/B,ucp,ascii_digit

/[[:graph:]]/B,ucp

/[[:print:]]/B,ucp

/[[:punct:]]/B,ucp

/[[:space:]]/B,ucp

/[[:word:]]/B,ucp

/[[:xdigit:]]/B,ucp

/[[:xdigit:]]/B,ucp,ascii_digit

# Unicode properties for \b and \B

/\b...\B/utf,ucp
    abc_
    \x{37e}abc\x{376}
    \x{37e}\x{376}\x{371}\x{393}\x{394}
    !\x{c0}++\x{c1}\x{c2}
    !\x{c0}+++++

# Without PCRE_UCP, non-ASCII always fail, even if < 256

/\b...\B/utf
    abc_
\= Expect no match
    \x{37e}abc\x{376}
    \x{37e}\x{376}\x{371}\x{393}\x{394}
    !\x{c0}++\x{c1}\x{c2}
    !\x{c0}+++++

# With PCRE_UCP, non-UTF8 chars that are < 256 still check properties

/\b...\B/ucp
    abc_
    !\x{c0}++\x{c1}\x{c2}
    !\x{c0}+++++

# Some of these are silly, but they check various combinations

/[[:^alpha:][:^cntrl:]]+/B,utf,ucp
    123
    abc

/[[:^cntrl:][:^alpha:]]+/B,utf,ucp
    123
    abc

/[[:alpha:]]+/B,utf,ucp
    abc

/[[:^alpha:]\S]+/B,utf,ucp
    123
    abc

/[^\d]+/B,utf,ucp
    abc123
    abc\x{123}
    \x{660}abc

/\p{Lu}+9\p{Lu}+B\p{Lu}+b/B

/\p{^Lu}+9\p{^Lu}+B\p{^Lu}+b/B

/\P{Lu}+9\P{Lu}+B\P{Lu}+b/B

/\p{Han}+X\p{Greek}+\x{370}/B,utf

/\p{Xan}+!\p{Xan}+A/B

/\p{Xsp}+!\p{Xsp}\t/B

/\p{Xps}+!\p{Xps}\t/B

/\p{Xwd}+!\p{Xwd}_/B

/A+\p{N}A+\dB+\p{N}*B+\d*/B,ucp

# These behaved oddly in Perl, so they are kept in this test

/(\x{23a}\x{23a}\x{23a})?\1/i,utf
\= Expect no match
    \x{23a}\x{23a}\x{23a}\x{2c65}\x{2c65}

/(ȺȺȺ)?\1/i,utf
\= Expect no match
    ȺȺȺⱥⱥ

/(\x{23a}\x{23a}\x{23a})?\1/i,utf
    \x{23a}\x{23a}\x{23a}\x{2c65}\x{2c65}\x{2c65}

/(ȺȺȺ)?\1/i,utf
    ȺȺȺⱥⱥⱥ

/(\x{23a}\x{23a}\x{23a})\1/i,utf
\= Expect no match
    \x{23a}\x{23a}\x{23a}\x{2c65}\x{2c65}

/(ȺȺȺ)\1/i,utf
\= Expect no match
    ȺȺȺⱥⱥ

/(\x{23a}\x{23a}\x{23a})\1/i,utf
    \x{23a}\x{23a}\x{23a}\x{2c65}\x{2c65}\x{2c65}

/(ȺȺȺ)\1/i,utf
    ȺȺȺⱥⱥⱥ

/(\x{2c65}\x{2c65})\1/i,utf
    \x{2c65}\x{2c65}\x{23a}\x{23a}

/(ⱥⱥ)\1/i,utf
    ⱥⱥȺȺ

/(\x{23a}\x{23a}\x{23a})\1Y/i,utf
    X\x{23a}\x{23a}\x{23a}\x{2c65}\x{2c65}\x{2c65}YZ

/(\x{2c65}\x{2c65})\1Y/i,utf
    X\x{2c65}\x{2c65}\x{23a}\x{23a}YZ

# These scripts weren't yet in Perl when I added Unicode 6.0.0 to PCRE

/^[\p{Batak}]/utf
    \x{1bc0}
    \x{1bff}
\= Expect no match
    \x{1bf4}

/^[\p{Brahmi}]/utf
    \x{11000}
    \x{1106f}
\= Expect no match
    \x{1104e}

/^[\p{Mandaic}]/utf
    \x{840}
    \x{85e}
\= Expect no match
    \x{85c}
    \x{85d}

/(\X*)(.)/s,utf
    A\x{300}

/^S(\X*)e(\X*)$/utf
    Stéréo

/^\X/utf
    ́réo

/^a\X41z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
    aX41z
\= Expect no match
    aAz

/\X/
    a\=ps
    a\=ph

/\Xa/
    aa\=ps
    aa\=ph

/\X{2}/
    aa\=ps
    aa\=ph

/\X+a/
    a\=ps
    aa\=ps
    aa\=ph

/\X+?a/
    a\=ps
    ab\=ps
    aa\=ps
    aa\=ph
    aba\=ps

# These Unicode 6.1.0 scripts are not known to Perl.

/\p{Chakma}\d/utf,ucp
    \x{11100}\x{1113c}

/\p{Takri}\d/utf,ucp
    \x{11680}\x{116c0}

/^\X/utf
    A\=ps
    A\=ph
    A\x{300}\x{301}\=ps
    A\x{300}\x{301}\=ph
    A\x{301}\=ps
    A\x{301}\=ph

/^\X{2,3}/utf
    A\=ps
    A\=ph
    AA\=ps
    AA\=ph
    A\x{300}\x{301}\=ps
    A\x{300}\x{301}\=ph
    A\x{300}\x{301}A\x{300}\x{301}\=ps
    A\x{300}\x{301}A\x{300}\x{301}\=ph

/^\X{2}/utf
    AA\=ps
    AA\=ph
    A\x{300}\x{301}A\x{300}\x{301}\=ps
    A\x{300}\x{301}A\x{300}\x{301}\=ph

/^\X+/utf
    AA\=ps
    AA\=ph

/^\X+?Z/utf
    AA\=ps
    AA\=ph

/A\x{3a3}B/IBi,utf

/[\x{3a3}]/Bi,utf

/[^\x{3a3}]/Bi,utf

/[\x{3a3}]+/Bi,utf

/[^\x{3a3}]+/Bi,utf

/a*\x{3a3}/Bi,utf

/\x{3a3}+a/Bi,utf

/\x{3a3}*\x{3c2}/Bi,utf

/\x{3a3}{3}/i,utf,aftertext
    \x{3a3}\x{3c3}\x{3c2}\x{3a3}\x{3c3}\x{3c2}

/\x{3a3}{2,4}/i,utf,aftertext
    \x{3a3}\x{3c3}\x{3c2}\x{3a3}\x{3c3}\x{3c2}

/\x{3a3}{2,4}?/i,utf,aftertext
    \x{3a3}\x{3c3}\x{3c2}\x{3a3}\x{3c3}\x{3c2}

/\x{3a3}+./i,utf,aftertext
    \x{3a3}\x{3c3}\x{3c2}\x{3a3}\x{3c3}\x{3c2}

/\x{3a3}++./i,utf,aftertext
\= Expect no match
    \x{3a3}\x{3c3}\x{3c2}\x{3a3}\x{3c3}\x{3c2}

/\x{3a3}*\x{3c2}/Bi,utf

/[^\x{3a3}]*\x{3c2}/Bi,utf

/[^a]*\x{3c2}/Bi,utf

/ist/Bi,utf
\= Expect no match
    ikt

/is+t/i,utf
    iSs\x{17f}t
\= Expect no match
    ikt

/is+?t/i,utf
\= Expect no match
    ikt

/is?t/i,utf
\= Expect no match
    ikt

/is{2}t/i,utf
\= Expect no match
    iskt

# This property is a PCRE special

/^\p{Xuc}/utf
    $abc
    @abc
    `abc
    \x{1234}abc
\= Expect no match
    abc

/^\p{Xuc}+/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^\p{Xuc}+?/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^\p{Xuc}+?\*/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^\p{Xuc}++/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^\p{Xuc}{3,5}/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^\p{Xuc}{3,5}?/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^[\p{Xuc}]/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^[\p{Xuc}]+/utf
    $@`\x{a0}\x{1234}\x{e000}**
\= Expect no match
    \x{9f}

/^\P{Xuc}/utf
    abc
\= Expect no match
    $abc
    @abc
    `abc
    \x{1234}abc

/^[\P{Xuc}]/utf
    abc
\= Expect no match
    $abc
    @abc
    `abc
    \x{1234}abc

# Some auto-possessification tests

/\pN+\z/B

/\PN+\z/B

/\pN+/B

/\PN+/B

/\p{Any}+\p{Any} \p{Any}+\P{Any} \p{Any}+\p{L&} \p{Any}+\p{L} \p{Any}+\p{Lu} \p{Any}+\p{Han} \p{Any}+\p{Xan} \p{Any}+\p{Xsp} \p{Any}+\p{Xps} \p{Xwd}+\p{Any} \p{Any}+\p{Xuc}/Bx,ucp

/\p{L&}+\p{Any} \p{L&}+\p{L&} \P{L&}+\p{L&} \p{L&}+\p{L} \p{L&}+\p{Lu} \p{L&}+\p{Han} \p{L&}+\p{Xan} \p{L&}+\P{Xan} \p{L&}+\p{Xsp} \p{L&}+\p{Xps} \p{Xwd}+\p{L&} \p{L&}+\p{Xuc}/Bx,ucp

/\p{N}+\p{Any} \p{N}+\p{L&} \p{N}+\p{L} \p{N}+\P{L} \p{N}+\P{N} \p{N}+\p{Lu} \p{N}+\p{Han} \p{N}+\p{Xan} \p{N}+\p{Xsp} \p{N}+\p{Xps} \p{Xwd}+\p{N} \p{N}+\p{Xuc}/Bx,ucp

/\p{Lu}+\p{Any} \p{Lu}+\p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\X \H+\X \h+\X \V+\X \v+\X a+\X \n+\X .+\X/Bx

/.+\X/Bsx

/\X+$/Bmx

/\X+\D \X+\d \X+\S \X+\s \X+\W \X+\w \X+. \X+\R \X+\H \X+\h \X+\V \X+\v \X+\X \X+\Z \X+\z \X+$/Bx

/\d+\s{0,5}=\s*\S?=\w{0,4}\W*/B,utf,ucp

/[RST]+/Bi,utf,ucp

/[R-T]+/Bi,utf,ucp

/[Q-U]+/Bi,utf,ucp

/^s?c/Iim,utf
    scat

/\X?abc/utf,no_start_optimize
    \xff\x7f\x00\x00\x03\x00\x41\xcc\x80\x41\x{300}\x61\x62\x63\x00\=no_utf_check,offset=06

/\x{100}\x{200}\K\x{300}/utf,startchar
    \x{100}\x{200}\x{300}

# Test UTF characters in a substitution

/ábc/utf,replace=XሴZ
    123ábc123

/(?<=abc)(|def)/g,utf,replace=<$0>
    123abcáyzabcdef789abcሴqr

/[A-`]/iB,utf
    abcdefghijklmno

/(?<=\K\x{17f})/g,utf,aftertext,allow_lookaround_bsk
    \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}

/(?<=\K\x{17f})/altglobal,utf,aftertext,allow_lookaround_bsk
    \x{17f}\x{17f}\x{17f}\x{17f}\x{17f}

"\xa\xf<(.\pZ*\P{Xwd}+^\xa8\3'3yq.::?(?J:()\xd1+!~:3'(8?:)':(?'d'(?'d'^u]!.+.+\\A\Ah(n+?9){7}+\K;(?'X'u'(?'c'(?'z'(?<y>\xb::\xf0'|\xd3(\xae?'w(z\x8?P>l)\x8?P>a)'\H\R\xd1+!!~:3'(?:h$N{26875}\W+?\\=D{2}\x89(?i:Uy0\N({2\xa(\v\x85*){y*\A(()\p{L}+?\P{^Xan}'+?\xff\+pS\?|).{;y*\A(()\p{L}+?\8}\d?1(|)(/1){7}.+[Lp{Me}].\s\xdcC*?(?(<y>))(?<!^)$C((;*?(R))+(\xbf(R))\x8a\X*?\x8a\xb\xd1^9\3*+(\xc1,\k'R'\xb4)\xcc(z\z(?J)(?'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?'R'\x1e;\x10:U))|')g!\xb0*){29+))#(?'P'})*?/

"(*UTF)(*UCP)(.UTF).+X(\V+;\^(\D|)!999}(?(?C{7(?C')\H*\S*/^\x5\xa\\xd3\x85n?(;\D*(?m).[^mH+((*UCP)(*U:F)})(?!^)(?'"

/[\pS#moq]/
    =

/(*:a\x{12345}b\t(d\)c)xxx/utf,alt_verbnames,mark
    cxxxz

/abcd/utf,replace=x\x{824}y\o{3333}z(\Q12\$34$$\x34\E5$$),substitute_extended
    abcd

/a(\x{e0}\x{101})(\x{c0}\x{102})/utf,replace=a\u$1\U$1\E$1\l$2\L$2\Eab\U\x{e0}\x{101}\L\x{d0}\x{160}\EDone,substitute_extended
    a\x{e0}\x{101}\x{c0}\x{102}

/((?<digit>\d)|(?<letter>\p{L}))/g,substitute_extended,replace=<${digit:+digit; :not digit; }${letter:+letter:not a letter}>
    ab12cde

/(*UCP)(*UTF)[[:>:]]X/B

/abc/utf,replace=xyz
    abc\=zero_terminate

/a[[:punct:]b]/ucp,bincode

/a[[:punct:]b]/utf,ucp,bincode

/a[b[:punct:]]/utf,ucp,bincode

/[[:^ascii:]]/utf,ucp,bincode

/[[:^ascii:]\w]/utf,ucp,bincode

/[\w[:^ascii:]]/utf,ucp,bincode

/[^[:ascii:]\W]/utf,ucp,bincode
    \x{de}
    \x{200}
\= Expect no match
    \x{589}
    \x{37e}

/[[:^ascii:]a]/utf,ucp,bincode

/L(?#(|++<!(2)?/B,utf,no_auto_possess,auto_callout

/L(?#(|++<!(2)?/B,utf,ucp,auto_callout

/(*UTF)C\x09((?<!'(?x)!*H? #\xcc\x9a[^$]/

/[\D]/utf
    \x{1d7cf}

/[\D\P{Nd}]/utf
    \x{1d7cf}

/[^\D]/utf
    a9b
\= Expect no match
    \x{1d7cf}

/[^\D\P{Nd}]/utf
    a9b
\= Expect no match
    \x{1d7cf}
    \x{10000}

# Hex uses pattern length, not zero-terminated. This tests for overrunning
# the given length of a pattern.

/'(*UTF)'/hex

/'#('/hex,extended,utf

/a(?<=A\XB)/utf

/../utf,auto_callout
    \n\x{123}\x{123}\x{123}\x{123}

# This tests processing wide characters in extended mode.

/XȀ/x,utf

# These three test a bug fix that was not clearing up after a locale setting
# when the test or a subsequent one matched a wide character.

//locale=C

/[\P{Yi}]/utf
\x{2f000}

/[\P{Yi}]/utf,locale=C
\x{2f000}

/^(?<!(?=􃡜))/B,utf

# Horizontal and vertical space lists ignore caseless

/[\HH]/Bi,utf

/[^\HH]/Bi,utf

//g,utf
    \=zero_terminate

/^(?1)\p{Nd}{3}(a)/
    a123a

/\p{Nd}{0,3}[\pL](*:abc)(?C1)xxx/callout_info

# ---------------------------------------------------------------------------

# A bunch of tests that hit lines of code that others do not (at least when
# these were created).

/^[^a]{3,}?x/i,utf,no_start_optimize,no_auto_possess
\= Expect no match
    bbb
    cc

/^[ac]{3,}?x/i,utf,no_start_optimize,no_auto_possess
\= Expect no match
    aaa\x{100}

/^X\X/no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\p{L&}+?/no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\p{L}+?/no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\p{Lu}+?/no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\p{Arabic}+?/no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\p{Xan}+?/ucp,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\s+?/ucp,no_start_optimize,no_auto_possess
\= Expect no match
    X
    XX

/^X\S+?/ucp,no_start_optimize,no_auto_possess
    XX
\= Expect no match
    X

/^X\w+?/ucp,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X[^\x{b5}]+?/i,utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X[\x{b5}]+?/i,utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\p{Xuc}+?/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X.+?Z/s,utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\R+?/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\H+?/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\V+?/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\s+?/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X
    XX

/^X\S+?/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X

/^X\p{Any}{1,3}?Z/s,no_start_optimize,no_auto_possess
    XYYYZ
\= Expect no match
    XY
    XYY
    XYYY
    XYYYYZ

/^X\p{L&}{1,3}?Z/s,no_start_optimize,no_auto_possess
\= Expect no match
    XY
    XY!

/^X\p{L}{1,3}?Z/s,no_start_optimize,no_auto_possess
\= Expect no match
    XY
    XY!

/^X\p{Lu}{1,3}?Z/s,no_start_optimize,no_auto_possess
\= Expect no match
    XY
    XY!

/^X\P{Han}{1,3}?Z/s,utf,no_start_optimize,no_auto_possess
\= Expect no match
    XY
    XY!
    XY\x{2f00}!

/^X\p{Xan}{1,3}?Z/s,no_start_optimize,no_auto_possess
\= Expect no match
    XY
    XY!

/^X\p{Xsp}{1,3}?Z/s,no_start_optimize,no_auto_possess
\= Expect no match
    X\n
    X\n!
    X\n\n! 

/^X\P{Xsp}{1,3}?Z/s,no_start_optimize,no_auto_possess
\= Expect no match
    XYY\n

/^X\p{Xwd}{1,3}?Z/s,no_start_optimize,no_auto_possess
\= Expect no match
    XY
    XY!
    XYY! 

/^X\x{b5}+?Z/i,utf,no_start_optimize,no_auto_possess
\= Expect no match
    X
    X\x{b5} 
    X\x{b5}\x{b5}Y 

/^X\p{Xuc}+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X
    X$
    X@@Y  

/(*CRLF)^X.+?Z/utf,no_start_optimize,no_auto_possess
\= Expect partial match
    XYY\r\=ph 
\= Expect no match
    X

/^X.+?Z/s,utf,no_start_optimize,no_auto_possess
\= Expect no match
    X
    XYY 

/^X\R+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X\nX
    X\n\rX
    X\n\r\nX
    X\n\n
    X\n\x{0c}    

/(*BSR_ANYCRLF)^X\R+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X\nX
    X\n\rX
    X\n\r\nX
    X\n\n
    X\n\x{0c}    

/^X\H+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    XY\t
    XYY 

/^X\h+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X\t\t
    X\tY

/^X\V+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    XY\n
    XYY 

/^X\v+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X\n\n
    X\nY

/^X\D+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    XY9
    XYY 

/^X\d+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X99
    X9Y

/^X\S+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    XY\n
    XYY 

/^X\s+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X\n\n
    X\nY

/^X\W+?Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X.A
    X++ 

/^X\p{L&}{1,3}Z/no_start_optimize,no_auto_possess
\= Expect no match
    XY
    XY!

/^X\p{L}{1,3}Z/no_start_optimize,no_auto_possess
\= Expect no match
    XY

/^X\p{Xan}{1,3}Z/no_start_optimize,no_auto_possess
\= Expect no match
    XY

/^X\P{Xsp}{1,3}Z/no_start_optimize,no_auto_possess
\= Expect no match
    XYY

/^X\p{Xuc}+Z/utf,no_start_optimize,no_auto_possess
\= Expect no match
    X$

# ----------------------------------------------------------------------
# These test the dangerous PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL option.

/\x{d800}/B,utf,bad_escape_is_literal

/\ud800/B,utf,alt_bsux,bad_escape_is_literal

# ----------------------------------------------------------------------

/Aሴ+B/literal,utf,no_utf_check
    Aሴ+B
    
# These are here because I upgraded to Unicode 10.0.0 before Perl did, so it
# doesn't recognize all these scripts. In time these three tests can be moved
# to test 4.

/^(\p{Adlam}+)(\p{Bhaiksuki}+)(\p{Marchen}+)(\p{Newa}+)(\p{Osage}+)
  (\p{Tangut}+)(\p{Masaram_Gondi}+)(\p{Nushu}+)(\p{Soyombo}+)
  (\p{Zanabazar_Square}+)/x,utf
    \x{1E900}\x{1E924}\x{1E953}\x{11C00}\x{11C2D}\x{11C3E}\x{11C70}\x{11C77}\x{11CAB}\x{11400}\x{1142F}\x{11455}\x{104B0}\x{104D8}\x{104FB}\x{16FE0}\x{18800}\x{18AF2}\x{11D00}\x{11D3A}\x{11D59}\x{16FE1}\x{1B170}\x{1B2FB}\x{11A50}\x{11A58}\x{11AA2}\x{11A00}\x{11A07}\x{11A47} 

/^\x{1E900}\x{104B0}/i,utf
    \x{1E900}\x{104B0}
    \x{1E922}\x{104D8}
    
/^(?:(\X)(?C))+$/utf
    \x{1E900}\x{1E924}\x{1E953}\x{11C00}\x{11C2D}\x{11C3E}\x{11C70}\x{11C77}\x{11CAB}\x{11400}\x{1142F}\x{11455}\x{104B0}\x{104D8}\x{104FB}\x{16FE0}\x{18800}\x{18AF2}\x{11D00}\x{11D3A}\x{11D59}\x{16FE1}\x{1B170}\x{1B2FB}\x{11A50}\x{11A58}\x{11AA2}\x{11A00}\x{11A07}\x{11A47}\=callout_capture,callout_no_where 

# Similarly for Unicode 11.0.0

/^(\p{Dogra}+)(\p{Gunjala_Gondi}+)(\p{Hanifi_Rohingya}+)(\p{Makasar}+)
  (\p{Medefaidrin}+)(\p{Old_Sogdian}+)(\p{Sogdian}+)/x,utf
    \x{11800}\x{11da9}\x{10d27}\x{11ee0}\x{16e48}\x{10f27}\x{10f30} 

# Regional indicators

/^(\X)(\X)/utf,aftertext
    \x{1F1E6}\x{1F1E7}\x{1F1E7}B
    \x{1F1E6}\x{1F1E7}\x{1F1E7}\x{1F1E6}B
    
# More differences from Perl

/^\p{Common}/utf
    \x{60c}
    \x{61f}  
    \x{964}
    \x{965}  

/^\p{Inherited}/utf
    \x{64b}
    \x{654}
    \x{655}
    \x{1D1AA} 

/\N{U+}/

/\N{U+}/utf

/\N{U}/

# This tests the non-UTF Unicode NEL pattern whitespace character, only
# recognized by PCRE2 with /x when there is Unicode support.

/A      

B/x
    AB 
    
# This tests Unicode Pattern White Space characters in verb names when they
# are being processed with PCRE2_EXTENDED. Note: there are UTF-8 characters
# with code points greater than 255 between A, B, and C in the pattern.

/(*: A‎B C)abc/x,utf,mark,alt_verbnames
    abc
    
# Script run tests: auto-possessification

/^(*sr:.*)/B,utf 
    paypаl.com   A classic example of why script run checks are a good thing

/^(*sr:.*(*ACCEPT))/utf 
    paypаl.com   But *ACCEPT breaks things

/^(*sr:\x{2e80}*)/B,utf

/^(*sr:\x{2e80}*)\x{2e80}/B,utf

/(?<!)(*sr:)/B

/(?<=abc(?=X(*sr:BXY)CCC)XBXYCCC)./B
   abcXBXYCCC!

# Some script run patterns are broken in Perl 5.28.0. These can be moved into
# test 4 when a mended version of Perl is released.

/^(*sr:.{4})/utf
    \x{0980}12\x{0993}     Bengali Common-digits Bengali
    \x{0780}12\x{07b1}     Thaana Common-digits Thaana
    \x{0e01}12\x{0e5b}     Thai Common-digits Thai
    \x{1780}12\x{19ff}     Khmer Common-digits Khmer
    \x{0904}12\x{0939}     Devanagari Common-digits Devanagari
    A\x{ff10}\x{ff19}B     Latin Common-notascii-digits Latin 
    A\x{1d7ce}\x{1d7cf}B   Latin fancy-common-digits Latin
    
# These ones involve non-ASCII but nevertheless Common digits. As of October
# 2018 even blead Perl wasn't handling all of these - but is going to. 

/^(*sr:.{4})/utf
    A\x{ff10}\x{ff19}B     Latin Common-notascii-digits Latin 
    \x{ff10}\x{ff19}..     Common-notascii-digits Common Common
    A\x{ff10}BC            Latin Common-notascii-digit Latin Latin
    A\x{1d7ce}\x{1d7cf}B   Latin fancy-common-digits Latin
    \x{1d7ce}\x{1d7cf},,   fancy-common-digits Common Common
    A\x{1d7ce}BC           Latin fancy-common-digit Latin Latin
    
# Some Unicode 12.1.0 new script characters

/\p{Elymaic}\p{Nandinagari}\p{Nyiakeng_Puachue_Hmong}\p{Wancho}/utf
    \x{10fe5}\x{119AC}\x{1E10E}\x{1E2D1} 

# Some Unicode 13.0.0 new script characters

/\p{Chorasmian}\p{Dives_Akuru}\p{Khitan_Small_Script}\p{Yezidi}/utf
    \x{10FB0}\x{11900}\x{18B00}\x{10E80}

# ------- 

# Test reference and errors in non-ASCII characters in group names

/(?'𑠅ABC'...)/I,utf
   abcde\=copy=𑠅ABC

# Bad ones

/(?'AB၌C'...)\g{AB၌C}/utf

/(?'٠ABC'...)/utf

/(?'²ABC'...)/utf

/(?'X²ABC'...)/utf

# -------

/\p{Any}*xyz/I

/(|)7/caseless,ucp

/(\xc1)\1/i,ucp
    \xc1\xe1\=no_jit
    
/\p{L&}+\p{bidi_control}/B

/\p{bidi_control}+\p{L&}/B

/\p{han}/B

/\p{script:han}/B

/\p{sc:han}/B

/\p{script extensions:han}/B

/\p{scx:han}/B

# Test error - invalid script name

/\p{sc:L}/

# Some Boolean property tests that differ from Perl

/\p{emojimodifierbase}\p{ebase}/g,utf
    >AN<>\x{261d}\x{1faf6}<>yz<

/\p{graphemelink}\p{grlink}/g,utf
    >AN<>\x{11d97}\x{94d}<>yz<
 
/\p{soft dotted}\p{sd}/g,utf
    >AF23<>\x{1df1a}\x{69}<>yz<
    
# ------------------------------------------------ 

/\p{\2b[:xigi:t:_/

# Tests for PCRE2_EXTRA_CASELESS_RESTRICT. Compare each test with and without
# the restriction.

/AskZ/i,utf,caseless_restrict
    AskZ
    aSKz
\= Expect no match
    A\x{17f}kZ
    As\x{212a}Z      

/AskZ/i,utf
    AskZ
    aSKz
    A\x{17f}kZ
    As\x{212a}Z      

/A\x{17f}\x{212a}Z/ir,utf
    \= Expect no match
    AskZ

/A\x{17f}\x{212a}Z/i,utf
    AskZ

/[AskZ]+/i,utf,caseless_restrict
    AskZ
    aSKz 
    A\x{17f}kZ
    As\x{212a}Z      

/[AskZ]+/i,utf
    AskZ
    aSKz 
    A\x{17f}kZ
    As\x{212a}Z      

/[\x{17f}\x{212a}]+/ir,utf
\= Expect no match
    AskZ

/[\x{17f}\x{212a}]+/i,utf
    AskZ

/[^s]+/ir,utf
    A\x{17f}Z 

/[^s]+/i,utf
    A\x{17f}Z 

/[^k]+/ir,utf
    A\x{212a}Z 
    
/[^k]+/i,utf
    A\x{212a}Z 
    
/[^sk]+/ir,utf
    A\x{17f}\x{212a}Z 

/[^sk]+/i,utf
    A\x{17f}\x{212a}Z 

/[^\x{17f}]+/ir,utf
    AsSZ 

/[^\x{17f}]+/i,utf
    AsSZ 

/[Ss]+/irB,utf
    Sss\x{17f}ss

/[Ss]+/iB,utf
    Sss\x{17f}ss

/[S\x{17f}]/irB,utf

/[S\x{17f}]/iB,utf

/[\x{17f}s]/irB,utf

/[\x{17f}s]/iB,utf

/[\x{4b}\x{6b}]/irB,utf

/[\x{4b}\x{6b}]/iB,utf

/s(?r)s(?-r)s(?r:s)s/i,utf
    \x{17f}S\x{17f}S\x{17f}
\= Expect no match     
    \x{17f}\x{17f}\x{17f}S\x{17f}
    \x{17f}S\x{17f}\x{17f}\x{17f}

/k(?^i)k/ir,utf
    K\x{212a}
\= Expect no match          
    \x{212a}\x{212a}

/[sk](?r:[sk])[sk]/Bi,utf
    SKS
    sks
    \x{212a}S\x{17f}
    \x{17f}K\x{212a}
\= Expect no match
    s\x{212a}s
    K\x{17f}K

/(.) \1/i,utf,caseless_restrict
    s S
    k K
\= Expect no match
    s \x{17f}
    k \x{212a}

/(.) (?r:\1)/i,utf
    s S
    k K
\= Expect no match
    s \x{17f}
    k \x{212a}

/(.) \1/i,utf
    s S
    k K
    s \x{17f}
    k \x{212a}

/(?:(?<A>ss)|(?<A>kk)) \k<A>/i,utf,dupnames,caseless_restrict
    sS Ss
    kK Kk
\= Expect no match
    sS \x{17f}s
    kK \x{212a}k

/(?:(?<A>ss)|(?<A>kk)) \k<A>/i,utf,dupnames
    sS Ss
    kK Kk
    sS \x{17f}s
    kK \x{212a}k

/(?:(?<A>s)|(?<A>k)) \k<A>{3,}!/i,utf,dupnames,caseless_restrict
    s SsSs!
    k KkKk!
\= Expect no match
    s \x{17f}sSs\x{17f}!
    k \x{212a}kKk\x{212a}!

/(?:(?<A>s)|(?<A>k)) \k<A>{3,}!/i,utf,dupnames
    s SsSs!
    k KkKk!
    s \x{17f}sSs\x{17f}!
    k \x{212a}kKk\x{212a}!

# End caseless restrict tests

# TESTS for PCRE2_EXTRA_TURKISH_CASING - again, tests with and without.

/i/i,utf
    i
    I
\= Expect no match
    \x{0130}
    \x{0131}

/i/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/I/i,utf
    i
    I
\= Expect no match
    \x{0130}
    \x{0131}

/I/i,utf,turkish_casing
    I
    \x{0131}
\= Expect no match
    i
    \x{0130}

/\x{0130}/i,utf
    \x{0130}
\= Expect no match
    i
    I
    \x{0131}

/\x{0130}/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/\x{0131}/i,utf
    \x{0131}
\= Expect no match
    i
    I
    \x{0130}

/\x{0131}/i,utf,turkish_casing
    I
    \x{0131}
\= Expect no match
    i
    \x{0130}

/[i]/i,utf
    i
    I
\= Expect no match
    \x{0130}
    \x{0131}

/[i]/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/[^i]/i,utf
    \x{0130}
    \x{0131}
\= Expect no match
    i
    I

/[^i]/i,utf,turkish_casing
    I
    \x{0131}
\= Expect no match
    i
    \x{0130}

/[\x{0130}]/i,utf
    \x{0130}
\= Expect no match
    i
    I
    \x{0131}

/[\x{0130}]/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/[\x{0120}-\x{0130}]/i,utf
    \x{0130}
\= Expect no match
    i
    I
    \x{0131}

/[\x{0120}-\x{0130}]/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/[zi]/i,utf
    i
    I
\= Expect no match
    \x{0130}
    \x{0131}

/[zi]/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/[z\x{0130}]/i,utf
    \x{0130}
\= Expect no match
    i
    I
    \x{0131}

/[z\x{0130}]/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/[iI]/i,utf
    i
    I
\= Expect no match
    \x{0130}
    \x{0131}

/[iI]/i,utf,turkish_casing
    i
    I
    \x{0130}
    \x{0131}

/[i\x{0130}]/i,utf
    i
    I
    \x{0130}
\= Expect no match
    \x{0131}

/[i\x{0130}]/i,utf,turkish_casing
    i
    \x{0130}
\= Expect no match
    I
    \x{0131}

/(.) \1/i,utf
    i I
\= Expect no match
    i \x{0130}
    \x{0131} I

/(*TURKISH_CASING)(.) \1/i,utf
    i \x{0130}
    \x{0131} I
\= Expect no match
    i I

/(.) \1/i,utf,turkish_casing
    i \x{0130}
    \x{0131} I
\= Expect no match
    i I

/i/i,utf,caseless_restrict,turkish_casing

/i/i,turkish_casing

/i/i,utf,caseless_restrict
    i

/i/i,ucp,caseless_restrict
    i

/b(?r:[\x{00FF}-\x{FFEE}])/i,utf,turkish_casing
    b\x{0130}
    b\x{0131}
\= Expect no match
    bi
    bI
    bk

/[\x60-\x7f]/i,ucp
    i
    I

/[\x60-\xc0]/i,ucp
    i
    I

/[\x80-\xc0]/i,ucp
\= Expect no match
    i
    I

# End Turkish casing tests

# TESTS for PCRE2_EXTRA_ASCII_xxx - again, tests with and without.

# DIGITS

/\d+/i,utf
    123\x{660}456

/\d+/i,utf,ucp
    123\x{660}456

/\d+/i,utf,ucp,ascii_bsd
    123\x{660}456

/[\d]+/i,utf
    123\x{660}456

/[\d]+/i,utf,ucp
    123\x{660}456

/[\d]+/i,utf,ucp,ascii_bsd
    123\x{660}456

/\d(?aD)\d(?-aD)\d/utf,ucp
    \x{660}9\x{660}
\= Expect no match     
    \x{660}\x{660}\x{660}

/\d(?-aD)\d(?aD)\d/utf,ucp,ascii_bsd
    999
    9\x{660}9

/\d(?a)\d(?-a)\d/utf,ucp
    \x{660}9\x{660}
\= Expect no match     
    \x{660}\x{660}\x{660}

/\d(?-aD)\d(?aD)\d/utf,ucp,ascii_bsd
    999
    9\x{660}9

# SPACES

/>\s+</i,utf
    >  <
\= Expect no match     
    >\x{a0} <

/>\s+</i,utf,ucp
    >  <
    >\x{a0} <

/>\s+</i,utf,ucp,ascii_bss
    >  <
\= Expect no match     
    >\x{a0} <

/>[\s]+</i,utf
    >  <
\= Expect no match     
    >\x{a0} <

/>[\s]+</i,utf,ucp
    >  <
    >\x{a0} <

/>[\s]+</i,utf,ucp,ascii_bss
    >  <
\= Expect no match     
    >\x{a0} <

/>\s(?aS)\s(?-aS)\s</utf,ucp
    >\x{a0} \x{a0}<
\= Expect no match     
    >\x{a0}\x{a0}\x{a0}<

/>\s(?a)\s(?-a)\s</utf,ucp
    >\x{a0} \x{a0}<
\= Expect no match     
    >\x{a0}\x{a0}\x{a0}<
    
# WORDS

/\w+/i,utf
    123\x{660}abc

/\w+/i,utf,ucp
    123\x{660}abc

/\w+/i,utf,ucp,ascii_bsw
    123\x{660}abc

/[\w]+/i,utf
    123\x{660}abc

/[\w]+/i,utf,ucp
    123\x{660}abc

/[\w]+/i,utf,ucp,ascii_bsw
    123\x{660}abc

/\w(?aW)\w(?-aW)\w/utf,ucp
    \x{660}A\x{c0}
\= Expect no match     
    \x{660}\x{c0}\x{c0}

/\w(?a)\w(?-a)\w/utf,ucp
    \x{660}A\x{c0}
\= Expect no match     
    \x{660}\x{c0}\x{c0}
    
# WORD BOUNDARY

/\bABC\b/utf
    \x{c0}ABC\x{d0}

/\bABC\b/utf,ucp
\= Expect no match
    \x{c0}ABC\x{d0}

/\bABC\b/utf,ucp,ascii_bsw
    \x{c0}ABC\x{d0}

/\bABC\b/utf,ucp,ascii_all
    \x{c0}ABC\x{d0}
    
# POSIX 

/^[[:digit:]]+$/utf,ucp
    123456
    123\x{660}456

/^[[:digit:]]+$/utf,ucp,ascii_digit
    123456
\= Expect no match
    123\x{660}456

/[[:digit:]]+/g,utf,ucp,ascii_digit
    123\x{660}456

/(?-aT)[[:digit:]](?aT)[[:digit:]]/utf,ucp,ascii_digit
    11
    \x{ff11}1
\= Expect no match
    1\x{ff11}

/(?-aT:[[:digit:]])[[:digit:]]/utf,ucp,ascii_digit
    11
    \x{ff11}1
\= Expect no match
    1\x{ff11}

/(?-aT:[[:digit:]])[[:digit:]]/utf,never_ucp,ascii_digit
    11
\= Expect no match
    \x{ff11}1
    1\x{ff11}

/[[:digit:]]+/utf,ucp,ascii_posix
    123\x{660}456

/(?-aP)[[:digit:]](?aP)[[:digit:]]/utf,ucp,ascii_posix
    11
    \x{ff11}1
\= Expect no match
    1\x{ff11}

/(?-aP:[[:digit:]])[[:digit:]]/utf,ucp,ascii_posix
    11
    \x{ff11}1
\= Expect no match
    1\x{ff11}

/(?-a:[[:digit:]])[[:digit:]]/a,utf,ucp
    11
    \x{ff11}1
\= Expect no match
    1\x{ff11}

/^[[:xdigit:]]+$/utf,ucp
    f0
    1A
    d\x{ff10}
    \x{ff26}8
\= Expect no match
    8g\=no_jit

/^[[:xdigit:]]+$/utf,ucp,ascii_digit
    f0
    1A
\= Expect no match
    d\x{ff10}
    \x{ff26}8
    8g

/>[[:space:]]+</utf,ucp
    >\x{a0} \x{a0}<
    >\x{a0}\x{a0}\x{a0}<

/>[[:space:]]+</utf,ucp,ascii_posix
\= Expect no match     
    >\x{a0} \x{a0}<

/(?aP)[[:alnum:]]+/i,ucp,utf
    abcáxyz
    abc\x{660}xyz

/(?aP)[[:alnum:]\d]+/i,ucp,utf
    abc\x{660}xyz
    
/(*UCP)(*UTF)[[:alnum:]](?aP:[[:alnum:]])[[:alnum:]]/
    \x{660}A\x{660}
\= Expect no match     
    \x{660}\x{660}\x{660}
    
# VARIOUS

/[\d\s\w]+/a,ucp,utf
    9 A\x{660}À 
    9 AÀ\x{660} 

# End PCRE2_EXTRA_ASCII_xxx tests

/(?<!(|l ))/utf
    (?<!(|l ))

/\p{  Aሴ}/utf

/\p{BC: Aሴ}/utf

/\p{BC: A=}/utf

/abc/utf,substitute_extended,replace=>\777<
    abc

/a(?<namED_1>b)c/utf,substitute_extended
    abc\=replace=>${namED_1}<

/a(?<namedverylongbutperfectlylegalsoyoushouldnthaveaproblem_1>b)c/utf,substitute_extended
    abc\=replace=>${namedverylongbutperfectlylegalsoyoushouldnthaveaproblem_1}<

/a(?<nämed>b)c/utf,substitute_extended
    abc\=replace=>${nämed}<

/a(?<nämedverylongbutperfectlylegalsoyoushouldnthaveaproblem_٢>b)c/utf,substitute_extended
    abc\=replace=>${nämedverylongbutperfectlylegalsoyoushouldnthaveaproblem_٢}<

# python_octal

/\400/utf
    \o{400}

/\400/utf,python_octal

/abc/utf,substitute_extended
    abc\=replace=\400

/abc/utf,substitute_extended,python_octal
    abc\=replace=\400

# Character range merging tests

/[\x{1200}\s\x{1202}\d\x{1201}]+/B,utf,ucp
    \x{11ff}\x{1200}\x{1201}\x{1202}\x{1203}

/[\x{2000}-\x{2500}\x{2100}-\x{2600}\d\x{1800}-\x{1fff}]+/B,utf,ucp
    \x{17ff}\x{1800}\x{2600}\x{2601}

/[\x{10008}\x{10003}\x{10006}\x{10004}\x{10007}]+/B,utf
    \x{10002}\x{10005}\x{10003}\x{10004}\x{10006}\x{10007}\x{10008}\x{10009}

/[\x{100}-\x{400}]+/Bi,utf
    qS\x{ff}\x{100}\x{a7c5}\x{401}
    \x{2c63}\x{2c64}\x{2c65}\x{2c66}\x{2c67}
    \x{a7af}\x{a7b0}\x{a7b1}\x{a7b2}\x{a7b3}

/[\x{100}-\x{400}\p{Ll}\x{500}-\x{700}\p{OldHungarian}\x{701}\p{bidiLRI}]/B,utf

/[\pC\x{100}-\x{200}\h\pN]/B,utf

/[\pC\x{100}-\x{200}\v\pN]/B,utf

/[\pC\x{100}-\x{200}\H\pN]/B,utf

/[\pC\x{100}-\x{200}\V\pN]/B,utf

/[\x{16e49}-\x{16e4f}\x{20000}\x{16e40}-\x{16e48}\pN]/Bi,utf

/[\x80-\x{4000}\x90\x{400}-\x{f000}\xa0\x{4000}-\x{10ffff}]++/B,utf
    \x{7f}\x{80}\x{100}\x{10fffe}\x{10ffff}\x00

/[\x80-\x{4000}\x90\x{400}-\x{f000}\xa0\pN\x{4000}-\x{10ffff}]++/B,utf
    \x{7f}\x{80}\x{100}090\x{10fffe}\x{10ffff}\x00

/[\x00-\x{4000}\x{2000}-\x{10ffff}]++/B,utf
    abcd

/[abc\p{Any}]{5,7}/B,utf
    xyz

/[^\p{Any}\x34\p{Any}]*cat/B,utf
    cat

/[\pN\xf0-\x{10ffff}]{5,8}/B,utf
    ab0123456cd

/[\x00-\x{398}\x{39a}-\x{10ffff}]*#(?i)[\x00-\x{398}\x{39a}-\x{10ffff}]*?#/B,utf
    abcd#efg#

# Freeing memory on error test
/[\x{100}-\x{400}][\x{100}-\x{300}][\x{100}-\x{200}]\8/i,utf

# Character list tests

/[\x{100}-\x{7fff}\x{d7b0}\x{d7b1}\x{d7b3}\x{d7b4}\x{d7b6}\x{d7b7}\x{d7b9}\x{d7ba}]{12}/B,utf
  \x{8000}\x{d7af}\x{d7b2}\x{d7b5}\x{d7b8}\x{d7bb}\x{100}\x{800}\x{7000}\x{7fff}\x{d7b0}\x{d7b1}\x{d7b3}\x{d7b4}\x{d7b6}\x{d7b7}\x{d7b9}\x{d7ba}\x{100}

/([\x{6535}\x{6536}\x{6538}\x{6539}\x{653b}\x{653c}\x{653e}\x{653f}\x{6541}\x{6542}\x{8000}-\x{ffff}]#)+/B,utf
  \x{6534}#\x{6537}#\x{653a}#\x{653d}#\x{6540}#\x{6543}#\x{7fff}#\x{6535}#\x{6536}#\x{6538}#\x{6539}#\x{653b}#\x{653c}#\x{653e}#\x{653f}#\x{6541}#\x{6542}#\x{8000}#\x{c246}#\x{ffff}

/[[:xdigit:]\x{400}-\x{600}]+/utf,ucp
  !a0\x{400}\x{600}9\x{3ff}

/[^[:xdigit:]\x{400}-\x{600}]+/utf,ucp
  \x{400}(\x{3ff}\x{601})\x{600}

/[[:xdigit:]\x{400}-\x{600}\x{700}]+/utf,ucp
  !A0\x{700}9\x{601}

/[^[:xdigit:]\x{400}-\x{600}\x{700}]+/utf,ucp
  \x{600}(\x{6ff}\x{701}\x{3ff}\x{601})\x{700}

/[[:xdigit:]\x{400}-\x{600}\x{700}-\x{800}\x{900}]+/utf,ucp
  !f0\x{800}\x{600}9\x{601}

/[^[:xdigit:]\x{400}-\x{600}\x{700}-\x{800}\x{900}]+/utf,ucp
  \x{700}[\x{3ff}\x{601}\x{6ff}\x{801}\x{8ff}\x{901}]\x{900}

/[[:xdigit:]\x{400}-\x{410}\x{500}\x{600}-\x{610}\x{700}\x{800}-\x{810}]+/utf,ucp
  !F0\x{400}\x{410}\x{500}\x{600}\x{610}\x{700}\x{800}\x{810}9\x{7ff}

/[^[:xdigit:]\x{400}-\x{410}\x{500}\x{600}-\x{610}\x{700}\x{800}-\x{810}]+/utf,ucp
  \x{800}<\x{3ff}\x{411}\x{4ff}\x{501}\x{5ff}\x{611}\x{6ff}\x{701}\x{7ff}\x{811}>\x{810}

# --------------

# EXTENDED CHARACTER CLASSES (UTS#18)

/[\p{Lu}[\p{Nd}]]/B,alt_extended_class
    0
    C
\= Expect no match
    [
    a

/[[\pL][\p{Nd}]]/B,alt_extended_class
    0
    a
\= Expect no match
    [
    ]

/[[\p{Lu}]||[\p{Nd}]]/B,alt_extended_class
    A
    1
\= Expect no match
    a

/[[^\pL][\p{Nd}]]/B,alt_extended_class
    0
    .
\= Expect no match
    A

/[^[\pL][\p{Nd}]]/B,alt_extended_class
    .
\= Expect no match
    A
    0

/[^[\pL]&&[\p{Nd}]]/B,alt_extended_class
    A
    0

/[[\p{Lu}\p{Ll}]||[\p{Nd}\p{Ll}]]/B,alt_extended_class
    A
    1
    c
\= Expect no match
    _

/[[\p{Lu}\p{Ll}]&&[\p{Nd}\p{Ll}]]/B,alt_extended_class
    c
\= Expect no match
    A
    1
    _

/[[\p{Lu}\p{Ll}]--[\p{Nd}\p{Ll}]]/B,alt_extended_class
    A
\= Expect no match
    1
    c
    _

/[[\p{Lu}\p{Ll}]~~[\p{Nd}\p{Ll}]]/B,alt_extended_class
    A
    1
\= Expect no match
    c
    _

/[\pL[]]]/B,alt_extended_class
    A
    ]
\= Expect no match
    [

/[\pL[^]]]/B,alt_extended_class
    A
    [
    0
\= Expect no match
    ]

/[\pL[]]/B,alt_extended_class,allow_empty_class
    A
\= Expect no match
    ]
    [

/[\pL[^]]/B,alt_extended_class,allow_empty_class
    A
    0
    [
    ]

/[\dAC-E[:space:]\p{Lu}&&[^z]]/B,alt_extended_class
    0
    A
    C
    D
    E
    \t
\= Expect no match
    a
    ;

/[z||[^\dAC-E[:space:]\p{Lu}]]/B,alt_extended_class
    z
    ;
\= Expect no match
    0
    A
    C
    D
    E
    B
    F
    \t

/[\p{Lu}\p{Nd}||cd]/B,alt_extended_class
    A
    0
    c
\= Expect no match
    e

/[[\p{Lu}]\p{Nd}||[c]d]/B,alt_extended_class
    A
    0
    c
\= Expect no match
    e

/[\p{Lu}[\p{Nd}]||c[d]]/B,alt_extended_class
    A
    0
    c
\= Expect no match
    e

/[\p{Lu}-]/B,alt_extended_class
    A
    -
\= Expect no match
    a

/[-\p{Lu}]/B,alt_extended_class
    A
    -
\= Expect no match
    a

/[\pL-]/B,alt_extended_class
    A
    -
\= Expect no match
    0

/[-\pL]/B,alt_extended_class
    A
    -
\= Expect no match
    0

/[\p{Lu}-]/B
    A
    -
\= Expect no match
    a

/[-\p{Lu}]/B
    A
    -
\= Expect no match
    a

/[\pL-]/B
    A
    -
\= Expect no match
    0

/[-\pL]/B
    A
    -
\= Expect no match
    0

/[\p{Lu}-z]/B,alt_extended_class

/[z-\p{Lu}]/B,alt_extended_class

/[\pL-z]/B,alt_extended_class

/[z-\pL]/B,alt_extended_class

/[\p{Lu}-&&-\pL]/B,alt_extended_class
    -
    A
\= Expect no match
    a

/[-\p{Lu}&&\pL-]/B,alt_extended_class
    -
    A
\= Expect no match
    a

/[[\p{Lu}]-&&-[\pL]]/B,alt_extended_class
    -
    A
\= Expect no match
    a

/[-[\p{Lu}]&&[\pL]-]/B,alt_extended_class
    -
    A
\= Expect no match
    a

/(?xx:[  ^  5[  ^  \p{Nd}]  ])/B,alt_extended_class
    4
\= Expect no match
    a
    ;
    5

/(?xx:[  ^  \p{Nd}[  ^  5]  ])/B,alt_extended_class
\= Expect no match
    a
    ;
    4
    5

/(?xx:[  ^  \p{Nd}[  ^  \p{Nd}]  ])/B,alt_extended_class
\= Expect no match
    a
    ;
    4
    5

/[  ^  \p{Ll}[  ^  \p{Nd}]  ]/B,alt_extended_class
    \x20
    ^
    a
    0
\= Expect no match
    A
    ;

/[a-c--\p{Nd}]+/B,alt_extended_class
    ac
    a
\= Expect no match
    0

/[a-c--\p{Nd}]{2,3}/B,alt_extended_class
    ac
    cac
\= Expect no match
    a
    00

/x[a-c--\p{Nd}]+y/B,alt_extended_class
    xacy
    xaay
    xay
\= Expect no match
    zacy
    xacz
    xy
    x0y

/[\pL--\pL--\pL]/B,alt_extended_class
\= Expect no match
    A
    1

/[[\pL--\pL]--\pL]/B,alt_extended_class
\= Expect no match
    A
    1

/[\pL--[\pL--\pL]]/B,alt_extended_class
    A
\= Expect no match
    1

/[\pL--^\p{Nd}]/B,alt_extended_class
    A
\= Expect no match
    1
    ^

/([a-z--[\pL&&n]])\1/B,alt_extended_class
    aa
    zz
\= Expect no match
    az
    nn

/(x[a-z--[\pL&&n]]y)\1/B,alt_extended_class
    xayxay
    xzyxzy
\= Expect no match
    xnyxny

/(?:_\1|([a-z--[\pL&&n]])){2}/B,alt_extended_class
    a_a
    z_z
\= Expect no match
    a_z
    n_n

/(?:_\1|([a-z--[\pL&&n]]))+/B,alt_extended_class
    a_a
    z_z
    a_partial
\= Expect no match
    n_n

/[\p{Nd}||[\pL--\p{Lu}]]/B,alt_extended_class
    a
    0
\= Expect no match
    C

/[\P{Nd}||2]/B,alt_extended_class
    _
    Z
    2
\= Expect no match
    1
    3

/[^[\P{Nd}]]/B,alt_extended_class
    1
    2
\= Expect no match
    _
    z

# caseless tests

/[\p{Lu}~~\p{Ll}]/B,alt_extended_class
    a
    A
\= Expect no match
    _
    1

/[[\p{Lu}1]~~\p{Ll}]/iB,alt_extended_class
    1
\= Expect no match
    a
    A
    _

/[[\p{Lu}1]&&[\p{Ll}1]]/B,alt_extended_class
    1
\= Expect no match
    a
    A
    _
    2

/[[\p{Lu}1]&&[\p{Ll}1]]/iB,alt_extended_class
    a
    A
    1
\= Expect no match
    _
    2
    \

/[\p{Thai}&&\p{Nd}]/B,utf,alt_extended_class
    \x{0e51}
\= Expect no match
    0
    a
    \x{0e01}

/[\p{Thai}||\p{Nd}]/B,utf,alt_extended_class
    \x{0e51}
    \x{0e01}
    0
\= Expect no match
    a

/[\p{Thai}~~\p{Nd}]/B,utf,alt_extended_class
    \x{0e01}
    0
\= Expect no match
    \x{0e51}
    a

/[[\p{Thai}&&\p{Nd}]~~[^a]]/B,utf,alt_extended_class
    \x{0e01}
    b
    0
\= Expect no match
    a
    \x{0e51}

/^[\p{Thai}&&\p{Nd}]?$/B,utf,alt_extended_class
    \x{0e51}
    \
\= Expect no match
    a

/^[\p{Thai}&&\p{Nd}]??$/B,utf,alt_extended_class
    \x{0e51}
    \
\= Expect no match
    a

/^[\p{Thai}&&\p{Nd}]?+$/B,utf,alt_extended_class
    \x{0e51}
    \
\= Expect no match
    a

/^[\p{Thai}&&\p{Nd}]{3}$/B,utf,alt_extended_class
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}
    \
    a

/^[\p{Thai}&&\p{Nd}]{3,}$/B,utf,alt_extended_class
    \x{0e51}\x{0e51}\x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}
    \
    a

/^[\p{Thai}&&\p{Nd}]{3,}?$/B,utf,alt_extended_class
    \x{0e51}\x{0e51}\x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}
    \
    a

/^[\p{Thai}&&\p{Nd}]{3,}+$/B,utf,alt_extended_class
    \x{0e51}\x{0e51}\x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}
    \
    a

/^[\p{Thai}&&\p{Nd}]{,3}$/B,utf,alt_extended_class
    \
    \x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}\x{0e51}\x{0e51}\x{0e51}
    a

/^[\p{Thai}&&\p{Nd}]{,3}?$/B,utf,alt_extended_class
    \
    \x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}\x{0e51}\x{0e51}\x{0e51}
    a

/^[\p{Thai}&&\p{Nd}]{,3}+$/B,utf,alt_extended_class
    \
    \x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}\x{0e51}\x{0e51}\x{0e51}
    a

/^[\p{Thai}&&\p{Nd}]+\x{0e51}$/B,utf,alt_extended_class
    \x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}
    \
    a

/^[\p{Thai}&&\p{Nd}]+?\x{0e51}$/B,utf,alt_extended_class
    \x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \x{0e51}
    \
    a

/^[\p{Thai}&&\p{Nd}]++\x{0e51}$/B,utf,alt_extended_class
\= Expect no match
    \x{0e51}
    \x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
    \
    a

/^[\p{Thai}&&\p{Nd}]*\x{0e51}$/B,utf,alt_extended_class
    \x{0e51}
    \x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \
    a

/^[\p{Thai}&&\p{Nd}]*?\x{0e51}$/B,utf,alt_extended_class
    \x{0e51}
    \x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
\= Expect no match
    \
    a

/^[\p{Thai}&&\p{Nd}]*+\x{0e51}$/B,utf,alt_extended_class
\= Expect no match
    \x{0e51}
    \x{0e51}\x{0e51}
    \x{0e51}\x{0e51}\x{0e51}
    \
    a

/[^[^\p{Thai}]]/B,utf,alt_extended_class
    \x{0e51}
\= Expect no match
    a

/[^[^\p{L}]]/B,utf,alt_extended_class
    \x{0e01}
    a
\= Expect no match
    0

/[\pL&&[^\x00-\xFF]]/B,utf,alt_extended_class
    \x{21e}
\= Expect no match
    a

/[\pL&&\x{100}-\x{1000}]{3,6}+/utf,alt_extended_class
    \x{145}\x{18b}A\x{145}\x{18b}\x{1C2}\x{21a}\x{257}\x{2ae}\x{0145}\x{18b}
    \x{145}A\x{145}\x{18b}\x{1C2}B

/[\pL&&\x{100}-\x{1000}]{3,6}\x{2A3}/utf,alt_extended_class
    \x{145}\x{18b}\x{2a3}A\x{145}\x{18b}\x{1c2}\x{21a}\x{257}\x{2ae}\x{2a3}
    \x{145}\x{2a3}A\x{145}\x{18b}\x{1c2}\x{2a3}
    \x{2a3}A\x{145}\x{18b}\x{1c2}\x{2a3}\x{2a3}
    \x{0145}\x{18b}\x{2a3}A\x{145}\x{18b}\x{1c2}\x{21a}\x{257}\x{2ae}\x{145}\x{2a3}

/[\pL&&\x{100}-\x{1000}]{3,6}?\x{2A3}/utf,alt_extended_class
    \x{145}\x{18b}\x{2a3}A\x{145}\x{18b}\x{1c2}\x{21a}\x{257}\x{2ae}\x{2a3}
    \x{145}\x{2a3}A\x{145}\x{18b}\x{1c2}\x{2a3}
    \x{2a3}A\x{145}\x{18b}\x{1c2}\x{2a3}\x{2a3}
    \x{0145}\x{18b}\x{2a3}A\x{145}\x{18b}\x{1c2}\x{21a}\x{257}\x{2ae}\x{145}\x{2a3}

/[\P{scx=Beng}\P{scx=Deva}\pM--[\x{2000}-\x{3000}]]+/utf,alt_extended_class
    \x{964}\x{2000}\x{3000}A\x{951}\x{1fff}\x{3001}\x{965}

/[\p{Thai}~~[^]]/B,utf,alt_extended_class,allow_empty_class
    \x{0d01}
    a
\= Expect no match
    \x{0e01}

/[[]~~[^]]/B,utf,alt_extended_class,allow_empty_class
    \x{0d01}
    a

/[[^]~~[]]/B,utf,alt_extended_class,allow_empty_class
    \x{0d01}
    a

/[[^]~~[^]]/B,utf,alt_extended_class,allow_empty_class
\= Expect no match
    \x{0d01}
    a

/[[^]||\pL]/B,utf,alt_extended_class,allow_empty_class
    0
    a

/[\pL||[^]]/B,utf,alt_extended_class,allow_empty_class
    0
    a

/[\pL~~[^]]/B,utf,alt_extended_class,allow_empty_class
    0
\= Expect no match
    a

/[[^]~~\pL]/B,utf,alt_extended_class,allow_empty_class
    0
\= Expect no match
    a

/([\p{Lu}&&\p{sc=Hung}]+?\x{10c81})+#/utf,alt_extended_class
    \x{10c80}\x{10cb2}\x{10c81}\x{10c85}\x{10cb0}\x{10cf2}\x{10c81}#\x{10c80}\x{10cb2}\x{10c81}\x{10c85}\x{10cb0}\x{10c81}##

/[[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||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[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]
&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]&&[\pN--[\pC||\x{9F5}]]]/utf,alt_extended_class

# --------------

/^([\h\x{9000}\x{9002}\x{9004}][\v\x{9000}\x{9002}\x{9004}\x{9006}\x{9008}][\h\v\x{9000}],){4}$/B,utf
  \x09\x0a\x0d,\x{1680}\x{2028}\x{1680},\x{180e}\x{2029}\x{180e},\x{9000}\x{9000}\x{9000},

/[z-\p{Lu}]/

/[z-\pL]/

/[\p{Lu}-z]/

/[\pL-z]/

/[a\x{e1}]/iB
    a
    A
    \x{e1}

/[a\x{e1}]/iB,utf
    a
    A
    \x{e1}
    \x{c1}

/[a\x{e1}]/iB,ucp
    a
    A
    \x{e1}
    \x{c1}

/[a\x{e1}]/iB,ucp,utf
    a
    A
    \x{e1}
    \x{c1}

# End of testinput5
