diff --git a/basis/pcre/pcre-tests.factor b/basis/pcre/pcre-tests.factor index 784ca91cb4..3963c5b2d4 100644 --- a/basis/pcre/pcre-tests.factor +++ b/basis/pcre/pcre-tests.factor @@ -10,6 +10,7 @@ USING: sequences system tools.test ; +QUALIFIED: regexp IN: pcre.tests CONSTANT: iso-date "(?P\\d{4})-(?P\\d{2})-(?P\\d{2})" @@ -117,3 +118,6 @@ os unix? [ [ 10 ] [ PCRE_CONFIG_NEWLINE config ] unit-test ] when "http://factorcode.org/" http-get nip "href=\"(?P[^\"]+)\"" findall [ "link" of ] map sequence? ] unit-test + +! Test that the regexp syntax works. +[ t ] [ "1234abcd" regexp:R[ ^\d+\w+$] matches? ] unit-test diff --git a/basis/pcre/pcre.factor b/basis/pcre/pcre.factor index 82f942c35c..008a04a90a 100644 --- a/basis/pcre/pcre.factor +++ b/basis/pcre/pcre.factor @@ -10,6 +10,7 @@ USING: pcre.ffi pcre.info pcre.utils sequences sequences.generalizations strings ; +QUALIFIED: regexp IN: pcre ERROR: malformed-regexp expr error ; @@ -90,6 +91,9 @@ M: compiled-pcre findall M: string findall findall ; +M: regexp:regexp findall + raw>> findall ; + : matches? ( subject obj -- ? ) dupd findall [ nip length 1 = ] [ ?first ?first ?last = ] 2bi and ;