]> gitweb.factorcode.org Git - factor.git/commitdiff
pcre: Stub documentation
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 6 Nov 2013 17:29:20 +0000 (18:29 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 20 Nov 2013 02:13:39 +0000 (18:13 -0800)
extra/pcre/pcre-docs.factor [new file with mode: 0644]

diff --git a/extra/pcre/pcre-docs.factor b/extra/pcre/pcre-docs.factor
new file mode 100644 (file)
index 0000000..be46d50
--- /dev/null
@@ -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 <compiled-pcre> }
+{ $examples
+  { $code
+    "USING: pcre ; "
+    "\"foobar\" \"\\\\w\" findall"
+  }
+}
+{ $notes "Regular expressions are by default utf8 and unicode aware." } ;
+
+HELP: <compiled-pcre>
+{ $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\" \"(?<ch1>\\\\w)(?<ch2>\\\\w)\" findall ."
+    "{"
+    "    { { f \"fo\" } { \"ch1\" \"f\" } { \"ch2\" \"o\" } }"
+    "    { { f \"ob\" } { \"ch1\" \"o\" } { \"ch2\" \"b\" } }"
+    "    { { f \"ar\" } { \"ch1\" \"a\" } { \"ch2\" \"r\" } }"
+    "}"
+  }
+} ;
+
+ABOUT: "pcre"