diff --git a/extra/pcre/pcre-docs.factor b/extra/pcre/pcre-docs.factor new file mode 100644 index 0000000000..be46d50337 --- /dev/null +++ b/extra/pcre/pcre-docs.factor @@ -0,0 +1,41 @@ +USING: help.markup help.syntax sequences strings ; +IN: pcre + +ARTICLE: "pcre" "PCRE binding" +"The " { $vocab-link "pcre" } " vocab implements a simple binding for libpcre, enabling rich regular expression support for Factor applications." +"Precompiling and optimizing a regular expression:" +{ $subsections } +{ $examples + { $code + "USING: pcre ; " + "\"foobar\" \"\\\\w\" findall" + } +} +{ $notes "Regular expressions are by default utf8 and unicode aware." } ; + +HELP: +{ $values + { "expr" string } +} +{ $description "Creates a precompiled regular expression object." } ; + +HELP: findall +{ $values + { "subject" string } + { "obj" "a string, compiled regular expression or a regexp literal" } + { "matches" sequence } +} +{ $description "Finds all matches of the given regexp in the string. Matches is sequence of associative array where the key is the name of the capturing group, or f to denote the full match." } +{ $examples + { $code + "USE: pcre" + "\"foobar\" \"(?\\\\w)(?\\\\w)\" findall ." + "{" + " { { f \"fo\" } { \"ch1\" \"f\" } { \"ch2\" \"o\" } }" + " { { f \"ob\" } { \"ch1\" \"o\" } { \"ch2\" \"b\" } }" + " { { f \"ar\" } { \"ch1\" \"a\" } { \"ch2\" \"r\" } }" + "}" + } +} ; + +ABOUT: "pcre"