USING: arrays regexp tools.test kernel sequences regexp.parser regexp.private eval strings multiline accessors ; IN: regexp.tests { f } [ "b" "a*" matches? ] unit-test { t } [ "" "a*" matches? ] unit-test { t } [ "a" "a*" matches? ] unit-test { t } [ "aaaaaaa" "a*" matches? ] unit-test { f } [ "ab" "a*" matches? ] unit-test { t } [ "abc" "abc" matches? ] unit-test { t } [ "a" "a|b|c" matches? ] unit-test { t } [ "b" "a|b|c" matches? ] unit-test { t } [ "c" "a|b|c" matches? ] unit-test { f } [ "c" "d|e|f" matches? ] unit-test { t } [ "b" "|b" matches? ] unit-test { t } [ "b" "b|" matches? ] unit-test { t } [ "" "b|" matches? ] unit-test { t } [ "" "b|" matches? ] unit-test { t } [ "" "|" matches? ] unit-test { t } [ "" "|||||||" matches? ] unit-test { f } [ "aa" "a|b|c" matches? ] unit-test { f } [ "bb" "a|b|c" matches? ] unit-test { f } [ "cc" "a|b|c" matches? ] unit-test { f } [ "cc" "d|e|f" matches? ] unit-test { f } [ "" "a+" matches? ] unit-test { t } [ "a" "a+" matches? ] unit-test { t } [ "aa" "a+" matches? ] unit-test { t } [ "" "a?" matches? ] unit-test { t } [ "a" "a?" matches? ] unit-test { f } [ "aa" "a?" matches? ] unit-test { f } [ "" "." matches? ] unit-test { t } [ "a" "." matches? ] unit-test { t } [ "." "." matches? ] unit-test ! Dotall mode -- when on, . matches newlines. ! Off by default. { f } [ "\n" "." matches? ] unit-test { t } [ "\n" "(?s:.)" matches? ] unit-test { t } [ "\n" re:: "." "s" matches? ] unit-test { f } [ "\n\n" "(?s:.)." matches? ] unit-test { f } [ "" ".+" matches? ] unit-test { t } [ "a" ".+" matches? ] unit-test { t } [ "ab" ".+" matches? ] unit-test { t } [ "\0" "[\\0]" matches? ] unit-test { f } [ "0" "[\\0]" matches? ] unit-test { t } [ " " "[\\s]" matches? ] unit-test { f } [ "a" "[\\s]" matches? ] unit-test { f } [ " " "[\\S]" matches? ] unit-test { t } [ "a" "[\\S]" matches? ] unit-test { f } [ " " "[\\w]" matches? ] unit-test { t } [ "a" "[\\w]" matches? ] unit-test { t } [ " " "[\\W]" matches? ] unit-test { f } [ "a" "[\\W]" matches? ] unit-test { t } [ "/" "\\/" matches? ] unit-test { t } [ "a" re:: "a" "i" matches? ] unit-test { t } [ "" "a|b*|c+|d?" matches? ] unit-test { t } [ "a" "a|b*|c+|d?" matches? ] unit-test { t } [ "c" "a|b*|c+|d?" matches? ] unit-test { t } [ "cc" "a|b*|c+|d?" matches? ] unit-test { f } [ "ccd" "a|b*|c+|d?" matches? ] unit-test { t } [ "d" "a|b*|c+|d?" matches? ] unit-test { t } [ "foo" "foo|bar" matches? ] unit-test { t } [ "bar" "foo|bar" matches? ] unit-test { f } [ "foobar" "foo|bar" matches? ] unit-test { f } [ "" "(a)" matches? ] unit-test { t } [ "a" "(a)" matches? ] unit-test { f } [ "aa" "(a)" matches? ] unit-test { t } [ "aa" "(a*)" matches? ] unit-test { f } [ "aababaaabbac" "(a|b)+" matches? ] unit-test { t } [ "ababaaabba" "(a|b)+" matches? ] unit-test { f } [ "" "a{1}" matches? ] unit-test { t } [ "a" "a{1}" matches? ] unit-test { f } [ "aa" "a{1}" matches? ] unit-test { f } [ "a" "a{2,}" matches? ] unit-test { t } [ "aaa" "a{2,}" matches? ] unit-test { t } [ "aaaa" "a{2,}" matches? ] unit-test { t } [ "aaaaa" "a{2,}" matches? ] unit-test { t } [ "" "a{,2}" matches? ] unit-test { t } [ "a" "a{,2}" matches? ] unit-test { t } [ "aa" "a{,2}" matches? ] unit-test { f } [ "aaa" "a{,2}" matches? ] unit-test { f } [ "aaaa" "a{,2}" matches? ] unit-test { f } [ "aaaaa" "a{,2}" matches? ] unit-test { f } [ "" "a{1,3}" matches? ] unit-test { t } [ "a" "a{1,3}" matches? ] unit-test { t } [ "aa" "a{1,3}" matches? ] unit-test { t } [ "aaa" "a{1,3}" matches? ] unit-test { f } [ "aaaa" "a{1,3}" matches? ] unit-test { f } [ "" "[a]" matches? ] unit-test { t } [ "a" "[a]" matches? ] unit-test { t } [ "a" "[abc]" matches? ] unit-test { f } [ "b" "[a]" matches? ] unit-test { f } [ "d" "[abc]" matches? ] unit-test { t } [ "ab" "[abc]{1,2}" matches? ] unit-test { f } [ "abc" "[abc]{1,2}" matches? ] unit-test { f } [ "" "[^a]" matches? ] unit-test { f } [ "a" "[^a]" matches? ] unit-test { f } [ "a" "[^abc]" matches? ] unit-test { t } [ "b" "[^a]" matches? ] unit-test { t } [ "d" "[^abc]" matches? ] unit-test { f } [ "ab" "[^abc]{1,2}" matches? ] unit-test { f } [ "abc" "[^abc]{1,2}" matches? ] unit-test { t } [ "]" "[]]" matches? ] unit-test { f } [ "]" "[^]]" matches? ] unit-test { t } [ "a" "[^]]" matches? ] unit-test [ "^" "[^]" matches? ] must-fail { t } [ "^" "[]^]" matches? ] unit-test { t } [ "]" "[]^]" matches? ] unit-test { t } [ "[" "[[]" matches? ] unit-test { f } [ "^" "[^^]" matches? ] unit-test { t } [ "a" "[^^]" matches? ] unit-test { t } [ "-" "[-]" matches? ] unit-test { f } [ "a" "[-]" matches? ] unit-test { f } [ "-" "[^-]" matches? ] unit-test { t } [ "a" "[^-]" matches? ] unit-test { t } [ "-" "[-a]" matches? ] unit-test { t } [ "a" "[-a]" matches? ] unit-test { t } [ "-" "[a-]" matches? ] unit-test { t } [ "a" "[a-]" matches? ] unit-test { f } [ "b" "[a-]" matches? ] unit-test { f } [ "-" "[^-]" matches? ] unit-test { t } [ "a" "[^-]" matches? ] unit-test { f } [ "-" "[a-c]" matches? ] unit-test { t } [ "-" "[^a-c]" matches? ] unit-test { t } [ "b" "[a-c]" matches? ] unit-test { f } [ "b" "[^a-c]" matches? ] unit-test { t } [ "-" "[a-c-]" matches? ] unit-test { f } [ "-" "[^a-c-]" matches? ] unit-test { t } [ "\\" "[\\\\]" matches? ] unit-test { f } [ "a" "[\\\\]" matches? ] unit-test { f } [ "\\" "[^\\\\]" matches? ] unit-test { t } [ "a" "[^\\\\]" matches? ] unit-test { t } [ "0" "[\\d]" matches? ] unit-test { f } [ "a" "[\\d]" matches? ] unit-test { f } [ "0" "[^\\d]" matches? ] unit-test { t } [ "a" "[^\\d]" matches? ] unit-test { t } [ "a" "[a-z]{1,}|[A-Z]{2,4}|b*|c|(f|g)*" matches? ] unit-test { t } [ "a" "[a-z]{1,2}|[A-Z]{3,3}|b*|c|(f|g)*" matches? ] unit-test { t } [ "a" "[a-z]{1,2}|[A-Z]{3,3}" matches? ] unit-test { t } [ "1000" "\\d{4,6}" matches? ] unit-test { t } [ "1000" "[0-9]{4,6}" matches? ] unit-test { t } [ "abc" "\\p{Lower}{3}" matches? ] unit-test { f } [ "ABC" "\\p{Lower}{3}" matches? ] unit-test { t } [ "ABC" "\\p{Upper}{3}" matches? ] unit-test { f } [ "abc" "\\p{Upper}{3}" matches? ] unit-test { f } [ "abc" "[\\p{Upper}]{3}" matches? ] unit-test { t } [ "ABC" "[\\p{Upper}]{3}" matches? ] unit-test { t } [ "" "\\Q\\E" matches? ] unit-test { f } [ "a" "\\Q\\E" matches? ] unit-test { t } [ "|*+" "\\Q|*+\\E" matches? ] unit-test { f } [ "abc" "\\Q|*+\\E" matches? ] unit-test { t } [ "s" "\\Qs\\E" matches? ] unit-test { t } [ "S" "\\0123" matches? ] unit-test { t } [ "SXY" "\\0123XY" matches? ] unit-test { t } [ "x" "\\x78" matches? ] unit-test { f } [ "y" "\\x78" matches? ] unit-test { t } [ "x" "\\u0078" matches? ] unit-test { f } [ "y" "\\u0078" matches? ] unit-test { t } [ "ab" "a+b" matches? ] unit-test { f } [ "b" "a+b" matches? ] unit-test { t } [ "aab" "a+b" matches? ] unit-test { f } [ "abb" "a+b" matches? ] unit-test { t } [ "abbbb" "ab*" matches? ] unit-test { t } [ "a" "ab*" matches? ] unit-test { f } [ "abab" "ab*" matches? ] unit-test { f } [ "x" "\\." matches? ] unit-test { t } [ "." "\\." matches? ] unit-test { t } [ "aaaab" "a+ab" matches? ] unit-test { f } [ "aaaxb" "a+ab" matches? ] unit-test { t } [ "aaacb" "a+cb" matches? ] unit-test { "aaa" } [ "aaacb" "a*" first-match >string ] unit-test { "aa" } [ "aaacb" "aa?" first-match >string ] unit-test { t } [ "aaa" re:: "AAA" "i" matches? ] unit-test { f } [ "aax" re:: "AAA" "i" matches? ] unit-test { t } [ "aaa" re:: "A*" "i" matches? ] unit-test { f } [ "aaba" re:: "A*" "i" matches? ] unit-test { t } [ "b" re:: "[AB]" "i" matches? ] unit-test { f } [ "c" re:: "[AB]" "i" matches? ] unit-test { t } [ "c" re:: "[A-Z]" "i" matches? ] unit-test { f } [ "3" re:: "[A-Z]" "i" matches? ] unit-test { t } [ "a" "(?i:a)" matches? ] unit-test { t } [ "a" "(?i:a)" matches? ] unit-test { t } [ "A" "(?i:a)" matches? ] unit-test { t } [ "A" "(?i:a)" matches? ] unit-test { t } [ "a" re:: "(?-i:a)" "i" matches? ] unit-test { t } [ "a" re:: "(?-i:a)" "i" matches? ] unit-test { f } [ "A" re:: "(?-i:a)" "i" matches? ] unit-test { f } [ "A" re:: "(?-i:a)" "i" matches? ] unit-test { f } [ "A" "[a-z]" matches? ] unit-test { t } [ "A" re:: "[a-z]" "i" matches? ] unit-test { f } [ "A" "\\p{Lower}" matches? ] unit-test { t } [ "A" re:: [[\p{Lower}]] "i" matches? ] unit-test { t } [ "abc" re:: "abc" "r" matches? ] unit-test { t } [ "abc" re:: "a[bB][cC]" "r" matches? ] unit-test { t } [ 3 "xabc" re:: "abc" "r" match-index-from >boolean ] unit-test { t } [ 3 "xabc" re:: "a[bB][cC]" "r" match-index-from >boolean ] unit-test { 2 } [ 0 "llamallol" re"ll" match-index-from ] unit-test { 5 } [ 8 "lolmallol" re:: "lol" "r" match-index-from ] unit-test { t } [ "s@f" "[a-z.-]@[a-z]" matches? ] unit-test { f } [ "a" "[a-z.-]@[a-z]" matches? ] unit-test { t } [ ".o" "\\.[a-z]" matches? ] unit-test { t } [ "abc*" "[^\\*]*\\*" matches? ] unit-test { t } [ "bca" "[^a]*a" matches? ] unit-test { } [ "(0[lL]?|[1-9]\\d{0,9}(\\d{0,9}[lL])?|0[xX]\\p{XDigit}{1,8}(\\p{XDigit}{0,8}[lL])?|0[0-7]{1,11}([0-7]{0,11}[lL])?|([0-9]+\\.[0-9]*|\\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?|[0-9]+([eE][+-]?[0-9]+[fFdD]?|([eE][+-]?[0-9]+)?[fFdD]))" drop ] unit-test { } [ "(\\$[\\p{XDigit}]|[\\p{Digit}])" drop ] unit-test ! Comment inside a regular expression { t } [ "ac" "a(?#boo)c" matches? ] unit-test { } [ "USING: regexp kernel ; re[[-{3}[+]{1,6}(?:!!)?\\s]] drop" eval( -- ) ] unit-test { } [ "USING: regexp kernel ; re[[(ftp|http|https):\\/\\/(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(\\/\\|\\/([\\w#!:.?+=&%@!\\-\\/]))?]] drop" eval( -- ) ] unit-test { } [ "USING: regexp kernel ; re[[\\*[^\s*][^*]*\\*]] drop" eval( -- ) ] unit-test { "ab" } [ "ab" "(a|ab)(bc)?" first-match >string ] unit-test { "abc" } [ "abc" "(a|ab)(bc)?" first-match >string ] unit-test { "ab" } [ "ab" "(ab|a)(bc)?" first-match >string ] unit-test { "abc" } [ "abc" "(ab|a)(bc)?" first-match >string ] unit-test { "b" } [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" first-match >string ] unit-test { T{ slice { from 5 } { to 10 } { seq "hellohello" } } } [ "hellohello" re:: "hello" "r" first-match ] unit-test { { "1" "2" "3" "4" } } [ "1ABC2DEF3GHI4" re"[A-Z]+" re-split [ >string ] map ] unit-test { { "1" "2" "3" "4" "" } } [ "1ABC2DEF3GHI4JK" re"[A-Z]+" re-split [ >string ] map ] unit-test { { "" } } [ "" re"=" re-split [ >string ] map ] unit-test { { "a" "" } } [ "a=" re"=" re-split [ >string ] map ] unit-test { { "he" "o" } } [ "hello" re"l+" re-split [ >string ] map ] unit-test { { "h" "llo" } } [ "hello" re"e+" re-split [ >string ] map ] unit-test { { "" "h" "" "l" "l" "o" "" } } [ "hello" re"e*" re-split [ >string ] map ] unit-test { { { 0 5 "hellohello" } { 5 10 "hellohello" } } } [ "hellohello" re"hello" [ 3array ] map-matches ] unit-test { { { 5 10 "hellohello" } { 0 5 "hellohello" } } } [ "hellohello" re:: "hello" "r" [ 3array ] map-matches ] unit-test { { "ABC" "DEF" "GHI" } } [ "1ABC2DEF3GHI4" re"[A-Z]+" all-matching-subseqs ] unit-test { { "ee" "e" } } [ "heellohello" re"e+" all-matching-subseqs ] unit-test { { "e" "ee" } } [ "heellohello" re:: "e+" "r" all-matching-subseqs ] unit-test { 3 } [ "1ABC2DEF3GHI4" re"[A-Z]+" count-matches ] unit-test { 3 } [ "1ABC2DEF3GHI4" re:: "[A-Z]+" "r" count-matches ] unit-test { 1 } [ "" re"" count-matches ] unit-test { 1 } [ "" re:: "" "r" count-matches ] unit-test { 0 } [ "123" re"[A-Z]+" count-matches ] unit-test { 0 } [ "123" re:: "[A-Z]+" "r" count-matches ] unit-test { 6 } [ "hello" re"e*" count-matches ] unit-test { 6 } [ "hello" re:: "e*" "r" count-matches ] unit-test { 11 } [ "hello world" re"l*" count-matches ] unit-test { 11 } [ "hello world" re:: "l*" "r" count-matches ] unit-test { 1 } [ "hello" re"e+" count-matches ] unit-test { 2 } [ "hello world" re:: "l+" "r" count-matches ] unit-test { "1.2.3.4." } [ "1ABC2DEF3GHI4JK" re"[A-Z]+" "." re-replace ] unit-test { "XhXXlXlXoX XwXoXrXlXdX" } [ "hello world" re"e*" "X" re-replace ] unit-test { "-- title --" } [ "== title ==" re"=" "-" re-replace ] unit-test { "abc" } [ "a/ \\bc" "/.*\\" "" re-replace ] unit-test { "ac" } [ "a/ \\bc" re[[\/.*\\.]] "" re-replace ] unit-test { "abc" } [ "a/ \\bc" re[[\/.*\\]] "" re-replace ] unit-test { "" } [ "ab" "a(?!b)" first-match >string ] unit-test { "a" } [ "ac" "a(?!b)" first-match >string ] unit-test { t } [ "fxxbar" ".{3}(?!foo)bar" matches? ] unit-test { t } [ "foobar" ".{3}(?!foo)bar" matches? ] unit-test { t } [ "fxxbar" "(?!foo).{3}bar" matches? ] unit-test { f } [ "foobar" "(?!foo).{3}bar" matches? ] unit-test { "a" } [ "ab" "a(?=b)(?=b)" first-match >string ] unit-test { "a" } [ "ba" "(?<=b)(?<=b)a" first-match >string ] unit-test { "a" } [ "cab" "(?<=c)a(?=b)" first-match >string ] unit-test { 3 } [ "foobar" "foo(?=bar)" first-match length ] unit-test { f } [ "foobxr" "foo(?=bar)" first-match ] unit-test ! Bug in parsing word { t } [ "a" re"a" matches? ] unit-test ! Testing negation { f } [ "a" re"(?~a)" matches? ] unit-test { t } [ "aa" re"(?~a)" matches? ] unit-test { t } [ "bb" re"(?~a)" matches? ] unit-test { t } [ "" re"(?~a)" matches? ] unit-test { f } [ "a" re"(?~a+|b)" matches? ] unit-test { f } [ "aa" re"(?~a+|b)" matches? ] unit-test { t } [ "bb" re"(?~a+|b)" matches? ] unit-test { f } [ "b" re"(?~a+|b)" matches? ] unit-test { t } [ "" re"(?~a+|b)" matches? ] unit-test ! Intersecting classes { t } [ "ab" re[[ac|\p{Lower}b]] matches? ] unit-test { t } [ "ab" re[[ac|[a-z]b]] matches? ] unit-test { t } [ "ac" re[[ac|\p{Lower}b]] matches? ] unit-test { t } [ "ac" re[[ac|[a-z]b]] matches? ] unit-test { t } [ "ac" re[[[a-zA-Z]c|\p{Lower}b]] matches? ] unit-test { t } [ "ab" re[[[a-zA-Z]c|\p{Lower}b]] matches? ] unit-test { t } [ "πb" re[[[a-zA-Z]c|\p{Lower}b]] matches? ] unit-test { f } [ "πc" re[[[a-zA-Z]c|\p{Lower}b]] matches? ] unit-test { f } [ "Ab" re[[[a-zA-Z]c|\p{Lower}b]] matches? ] unit-test { t } [ "aaaa" re".*a." matches? ] unit-test { f } [ "ab" re[[(?~ac|\p{Lower}b)]] matches? ] unit-test { f } [ "ab" re[[(?~ac|[a-z]b)]] matches? ] unit-test { f } [ "ac" re[[(?~ac|\p{Lower}b)]] matches? ] unit-test { f } [ "ac" re[[(?~ac|[a-z]b)]] matches? ] unit-test { f } [ "ac" re[[(?~[a-zA-Z]c|\p{Lower}b)]] matches? ] unit-test { f } [ "ab" re[[(?~[a-zA-Z]c|\p{Lower}b)]] matches? ] unit-test { f } [ "πb" re[[(?~[a-zA-Z]c|\p{Lower}b)]] matches? ] unit-test { t } [ "πc" re[[(?~[a-zA-Z]c|\p{Lower}b)]] matches? ] unit-test { t } [ "Ab" re[[(?~[a-zA-Z]c|\p{Lower}b)]] matches? ] unit-test ! DFA is compiled when needed, or when literal { regexp-initial-word } [ "foo" dfa>> ] unit-test { f } [ re"foo" dfa>> \ regexp-initial-word = ] unit-test { t } [ "a" re"^a" matches? ] unit-test { f } [ "\na" re"^a" matches? ] unit-test { f } [ "\r\na" re"^a" matches? ] unit-test { f } [ "\ra" re"^a" matches? ] unit-test { 1 } [ "a" re"^a" count-matches ] unit-test { 0 } [ "\na" re"^a" count-matches ] unit-test { 0 } [ "\r\na" re"^a" count-matches ] unit-test { 0 } [ "\ra" re"^a" count-matches ] unit-test { t } [ "a" re"a$" matches? ] unit-test { f } [ "a\n" re"a$" matches? ] unit-test { f } [ "a\r" re"a$" matches? ] unit-test { f } [ "a\r\n" re"a$" matches? ] unit-test { 1 } [ "a" re"a$" count-matches ] unit-test { 0 } [ "a\n" re"a$" count-matches ] unit-test { 0 } [ "a\r" re"a$" count-matches ] unit-test { 0 } [ "a\r\n" re"a$" count-matches ] unit-test { t } [ "a" re"a$|b$" matches? ] unit-test { t } [ "b" re"a$|b$" matches? ] unit-test { f } [ "ab" re"a$|b$" matches? ] unit-test { t } [ "ba" re"ba$|b$" matches? ] unit-test { t } [ "a" re[[\Aa]] matches? ] unit-test { f } [ "\na" re[[\Aaa]] matches? ] unit-test { f } [ "\r\na" re[[\Aa]] matches? ] unit-test { f } [ "\ra" re[[\Aa]] matches? ] unit-test { t } [ "a" re:: [[\Aa]] "m" matches? ] unit-test { f } [ "\na" re:: [[\Aaa]] "m" matches? ] unit-test { f } [ "\r\na" re:: [[\Aa]] "m" matches? ] unit-test { f } [ "\ra" re:: [[\Aa]] "m" matches? ] unit-test { 0 } [ "\ra" re:: [[\Aa]] "m" count-matches ] unit-test { f } [ "\r\n\n\n\nam" re:: [[^am]] "m" matches? ] unit-test { 1 } [ "\r\n\n\n\nam" re:: [[^am]] "m" count-matches ] unit-test { t } [ "a" re:: [[\Aa\z]] "m" matches? ] unit-test { f } [ "a\n" re:: [[\Aa\z]] "m" matches? ] unit-test { f } [ "a\r\n" re:: [[\Aa\Z]] "m" matches? ] unit-test { f } [ "a\n" re:: [[\Aa\Z]] "m" matches? ] unit-test { 1 } [ "a\r\n" re:: [[\Aa\Z]] "m" count-matches ] unit-test { 1 } [ "a\n" re:: [[\Aa\Z]] "m" count-matches ] unit-test { t } [ "a" re:: [[\Aa\Z]] "m" matches? ] unit-test { f } [ "\na" re:: [[\Aaa\Z]] "m" matches? ] unit-test { f } [ "\r\na" re:: [[\Aa\Z]] "m" matches? ] unit-test { f } [ "\ra" re:: [[\Aa\Z]] "m" matches? ] unit-test { 1 } [ "a" re:: [[\Aa\Z]] "m" count-matches ] unit-test { 0 } [ "\na" re:: [[\Aaa\Z]] "m" count-matches ] unit-test { 0 } [ "\r\na" re:: [[\Aa\Z]] "m" count-matches ] unit-test { 0 } [ "\ra" re:: [[\Aa\Z]] "m" count-matches ] unit-test { t } [ "a" re:: "^a" "m" matches? ] unit-test { f } [ "\na" re:: "^a" "m" matches? ] unit-test { 1 } [ "\na" re:: "^a" "m" count-matches ] unit-test { 1 } [ "\r\na" re:: "^a" "m" count-matches ] unit-test { 1 } [ "\ra" re:: "^a" "m" count-matches ] unit-test { t } [ "a" re:: "a$" "m" matches? ] unit-test { f } [ "a\n" re:: "a$" "m" matches? ] unit-test { 1 } [ "a\n" re:: "a$" "m" count-matches ] unit-test { 1 } [ "a\r" re:: "a$" "m" count-matches ] unit-test { 1 } [ "a\r\n" re:: "a$" "m" count-matches ] unit-test { f } [ "foobxr" "foo\\z" first-match ] unit-test { 3 } [ "foo" "foo\\z" first-match length ] unit-test { t } [ "a foo b" re"foo" re-contains? ] unit-test { f } [ "a bar b" re"foo" re-contains? ] unit-test { t } [ "foo" re"foo" re-contains? ] unit-test { { "foo" "fxx" "fab" } } [ "fab fxx foo" re:: "f.." "r" all-matching-subseqs ] unit-test { t } [ "foo" "\\bfoo\\b" re-contains? ] unit-test { t } [ "afoob" "\\Bfoo\\B" re-contains? ] unit-test { f } [ "afoob" "\\bfoo\\b" re-contains? ] unit-test { f } [ "foo" "\\Bfoo\\B" re-contains? ] unit-test { 3 } [ "foo bar" "foo\\b" first-match length ] unit-test { f } [ "fooxbar" "foo\\b" re-contains? ] unit-test { t } [ "foo" "foo\\b" re-contains? ] unit-test { t } [ "foo bar" "foo\\b bar" matches? ] unit-test { f } [ "fooxbar" "foo\\bxbar" matches? ] unit-test { f } [ "foo" "foo\\bbar" matches? ] unit-test { f } [ "foo bar" "foo\\B" re-contains? ] unit-test { 3 } [ "fooxbar" "foo\\B" first-match length ] unit-test { f } [ "foo" "foo\\B" re-contains? ] unit-test { f } [ "foo bar" "foo\\B bar" matches? ] unit-test { t } [ "fooxbar" "foo\\Bxbar" matches? ] unit-test { f } [ "foo" "foo\\Bbar" matches? ] unit-test { t } [ "ab" "a(?=b*)" re-contains? ] unit-test { t } [ "abbbbbc" "a(?=b*c)" re-contains? ] unit-test { f } [ "abbbbb" "a(?=b*c)" re-contains? ] unit-test { t } [ "ab" "a(?=b*)" re-contains? ] unit-test { "az" } [ "baz" "(?<=b)(az)" first-match >string ] unit-test { f } [ "chaz" "(?<=b)(az)" re-contains? ] unit-test { "a" } [ "cbaz" "(?<=b*)a" first-match >string ] unit-test { f } [ "baz" "a(?<=b)" re-contains? ] unit-test { f } [ "baz" "(? re-contains? ] unit-test { t } [ "caz" "(? re-contains? ] unit-test { "abcd" } [ "abcdefg" "a(?=bcdefg)bcd" first-match >string ] unit-test { t } [ "abcdefg" "a(?#bcdefg)bcd" re-contains? ] unit-test { t } [ "abcdefg" "a(?:bcdefg)" matches? ] unit-test { 3 } [ "caba" "(?<=b)a" first-match from>> ] unit-test { t } [ "\ra" re:: ".^a" "ms" matches? ] unit-test { f } [ "\ra" re:: ".^a" "mds" matches? ] unit-test { t } [ "\na" re:: ".^a" "ms" matches? ] unit-test { t } [ "\na" re:: ".^a" "mds" matches? ] unit-test { t } [ "a\r" re:: "a$." "ms" matches? ] unit-test { f } [ "a\r" re:: "a$." "mds" matches? ] unit-test { t } [ "a\n" re:: "a$." "ms" matches? ] unit-test { t } [ "a\n" re:: "a$." "mds" matches? ] unit-test ! Unicode categories { t } [ "a" re[[\p{L}]] matches? ] unit-test { t } [ "A" re[[\p{L}]] matches? ] unit-test { f } [ " " re[[\p{L}]] matches? ] unit-test { f } [ "a" re[[\P{L}]] matches? ] unit-test { f } [ "A" re[[\P{L}]] matches? ] unit-test { t } [ " " re[[\P{L}]] matches? ] unit-test { t } [ "a" re[[\p{Ll}]] matches? ] unit-test { f } [ "A" re[[\p{Ll}]] matches? ] unit-test { f } [ " " re[[\p{Ll}]] matches? ] unit-test { f } [ "a" re[[\P{Ll}]] matches? ] unit-test { t } [ "A" re[[\P{Ll}]] matches? ] unit-test { t } [ " " re[[\P{Ll}]] matches? ] unit-test { t } [ "a" re[[\p{script=Latin}]] matches? ] unit-test { f } [ " " re[[\p{script=Latin}]] matches? ] unit-test { f } [ "a" re[[\P{script=Latin}]] matches? ] unit-test { t } [ " " re[[\P{script=Latin}]] matches? ] unit-test ! These should be case-insensitive { f } [ " " re[[\p{l}]] matches? ] unit-test { f } [ "a" re[[\P{l}]] matches? ] unit-test { f } [ "a" re[[\P{ll}]] matches? ] unit-test { t } [ " " re[[\P{LL}]] matches? ] unit-test { f } [ "a" re[[\P{sCriPt = latin}]] matches? ] unit-test { t } [ " " re[[\P{SCRIPT = laTIn}]] matches? ] unit-test ! Logical operators { t } [ "a" re[=[[\p{script=latin}\p{lower}]]=] matches? ] unit-test { t } [ "π" re[=[[\p{script=latin}\p{lower}]]=] matches? ] unit-test { t } [ "A" re[=[[\p{script=latin}\p{lower}]]=] matches? ] unit-test { f } [ "3" re[=[[\p{script=latin}\p{lower}]]=] matches? ] unit-test { t } [ "a" re[=[[\p{script=latin}||\p{lower}]]=] matches? ] unit-test { t } [ "π" re[=[[\p{script=latin}||\p{lower}]]=] matches? ] unit-test { t } [ "A" re[=[[\p{script=latin}||\p{lower}]]=] matches? ] unit-test { f } [ "3" re[=[[\p{script=latin}||\p{lower}]]=] matches? ] unit-test { t } [ "a" re[=[[\p{script=latin}&&\p{lower}]]=] matches? ] unit-test { f } [ "π" re[=[[\p{script=latin}&&\p{lower}]]=] matches? ] unit-test { f } [ "A" re[=[[\p{script=latin}&&\p{lower}]]=] matches? ] unit-test { f } [ "3" re[=[[\p{script=latin}&&\p{lower}]]=] matches? ] unit-test { f } [ "a" re[=[[\p{script=latin}~~\p{lower}]]=] matches? ] unit-test { t } [ "π" re[=[[\p{script=latin}~~\p{lower}]]=] matches? ] unit-test { t } [ "A" re[=[[\p{script=latin}~~\p{lower}]]=] matches? ] unit-test { f } [ "3" re[=[[\p{script=latin}~~\p{lower}]]=] matches? ] unit-test { f } [ "a" re[=[[\p{script=latin}--\p{lower}]]=] matches? ] unit-test { f } [ "π" re[=[[\p{script=latin}--\p{lower}]]=] matches? ] unit-test { t } [ "A" re[=[[\p{script=latin}--\p{lower}]]=] matches? ] unit-test { f } [ "3" re[=[[\p{script=latin}--\p{lower}]]=] matches? ] unit-test { t } [ " " re[[\P{alpha}]] matches? ] unit-test { f } [ "" re[[\P{alpha}]] matches? ] unit-test { f } [ "a " re[[\P{alpha}]] matches? ] unit-test { f } [ "a" re[[\P{alpha}]] matches? ] unit-test