]> gitweb.factorcode.org Git - factor.git/blob - extra/pcre/pcre-docs.factor
Fixes #2966
[factor.git] / extra / pcre / pcre-docs.factor
1 USING: help.markup help.syntax math sequences strings ;
2 IN: pcre
3
4 ARTICLE: "pcre" "PCRE binding"
5 "The " { $vocab-link "pcre" } " vocab implements a simple binding for libpcre, enabling rich regular expression support for Factor applications." $nl
6 "Precompiling and optimizing a regular expression:"
7 { $subsections <compiled-pcre> }
8 { $examples
9   { $code
10     "USING: pcre ; "
11     "\"foobar\" \"\\\\w\" findall"
12   }
13 }
14 { $notes "Regular expressions are by default utf8 and unicode aware." } ;
15
16 HELP: <compiled-pcre>
17 { $values { "expr" string } { "compiled-pcre" compiled-pcre } }
18 { $description "Creates a precompiled regular expression object." } ;
19
20 HELP: findall
21 { $values
22   { "subject" string }
23   { "obj" "a string, compiled regular expression or a regexp literal" }
24   { "matches" sequence }
25 }
26 { $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." }
27 { $examples
28   { $code
29     "USE: pcre"
30     "\"foobar\" \"(?<ch1>\\\\w)(?<ch2>\\\\w)\" findall ."
31     "{"
32     "    { { f \"fo\" } { \"ch1\" \"f\" } { \"ch2\" \"o\" } }"
33     "    { { f \"ob\" } { \"ch1\" \"o\" } { \"ch2\" \"b\" } }"
34     "    { { f \"ar\" } { \"ch1\" \"a\" } { \"ch2\" \"r\" } }"
35     "}"
36   }
37 } ;
38
39 HELP: version
40 { $values { "f" float } }
41 { $description "Version number of the PCRE library, expressed as a float." } ;
42
43 ABOUT: "pcre"