8 pcre pcre.ffi pcre.info
16 CONSTANT: iso-date "(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})"
18 ! On windows the erroffset appears to be set to 0 despite there being
19 ! nothing wrong with the regexp.
21 "foo" (pcre) 3array 1 tail { { f -1 } { f 0 } } member?
26 { "year" "month" "day" } [ pcre_get_stringnumber ] with map
29 [ t ] [ "foo" <compiled-pcre> PCRE_UTF8 has-option? ] unit-test
31 os unix? [ [ 10 ] [ PCRE_CONFIG_NEWLINE config ] unit-test ] when
33 ! In this day and age, not supporting utf-8 is broken.
34 [ 1 ] [ PCRE_CONFIG_UTF8 config ] unit-test
36 [ 1 ] [ PCRE_CONFIG_UNICODE_PROPERTIES config ] unit-test
38 ! libpcre must not support 16 or 32 bit code points.
39 [ 0 ] [ PCRE_CONFIG_UTF16 config ] unit-test
40 [ 0 ] [ PCRE_CONFIG_UTF32 config ] unit-test
44 { { f "1999-01-12" } { "year" "1999" } { "month" "01" } { "day" "12" } }
46 "1999-01-12" iso-date <compiled-pcre> findall first
50 "2003-10-09 1999-09-01 1514-10-20" iso-date <compiled-pcre> findall length
53 [ 5 ] [ "abcdef" "[a-e]" findall length ] unit-test
55 [ 3 ] [ "foo bar baz" "foo|bar|baz" findall length ] unit-test
57 [ 3 ] [ "örjan är åtta" "[åäö]" findall length ] unit-test
59 [ 3 ] [ "ÅÄÖ" "\\p{Lu}" findall length ] unit-test
61 [ 3 ] [ "foobar" "foo(?=bar)" findall first first second length ] unit-test
63 [ { { { f ", " } } { { f ", " } } { { f "." } } } ] [
64 "Words, words, word." "\\W+" findall
67 [ { ", " ", " "." } ] [
68 "Words, words, word." "\\W+" findall [ first second ] map
71 : long-string ( -- x )
72 10000 [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
75 [ 0 ] [ long-string ".{0,15}foobar.{0,10}" findall length ] unit-test
77 ! Empty matches, corner case behaviour is copied from pcredemo.c
78 [ { { { f "foo" } } { { f "" } } } ]
79 [ "foo" ".*" findall ] unit-test
81 [ { { { f "" } } { { f "" } } { { f "" } } } ]
82 [ "foo" "B*" findall ] unit-test
84 ! Empty matches in strings with multi-byte characters are tricky.
85 [ { { { f "" } } { { f "" } } { { f "" } } { { f "" } } } ]
86 [ "öööö" "x*" findall ] unit-test
89 [ t ] [ "örjan" "örjan" matches? ] unit-test
91 [ t ] [ "abcö" "\\p{Ll}{4}" matches? ] unit-test
93 ! Dotall mode, off by default
94 [ f ] [ "." <compiled-pcre> PCRE_DOTALL has-option? ] unit-test
95 [ t ] [ "(?s)." <compiled-pcre> PCRE_DOTALL has-option? ] unit-test
97 [ f ] [ "\n" "." matches? ] unit-test
98 [ t ] [ "\n" "(?s)." matches? ] unit-test
100 ! Caseless mode, off by default
102 { "x" "(?i)x" } [ <compiled-pcre> PCRE_CASELESS has-option? ] map
107 { "response and responsibility" "sense and responsibility" }
108 [ "(sens|respons)e and \\1ibility" matches? ] map
112 { "rah rah" "RAH RAH" "RAH rah" } [ "((?i)rah)\\s+\\1" matches? ] map
116 [ { { "Words" "words" "word" } { "Words" "words" "word" } } ] [
117 "Words, words, word." { "\\W+" "[,. ]" } [ split ] with map
122 "http://factorcode.org/" http-get nip
123 "href=\"(?P<link>[^\"]+)\"" findall [ "link" of ] map sequence?
126 ! Test that the regexp syntax works.
127 [ t ] [ "1234abcd" regexp:R[ ^\d+\w+$] matches? ] unit-test