! Copyright (C) 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: help.syntax help.markup regexp strings ; IN: regexp.combinators ABOUT: "regexp.combinators" ARTICLE: "regexp.combinators.intro" "Regular expression combinator rationale" "Regular expression combinators are useful when part of the regular expression contains user input. For example, given a sequence of strings on the stack, a regular expression which matches any one of them can be constructed:" { $code "[ ] map " } "Without combinators, a naive approach would look as follows:" { $code "\"|\" join " } "However, this code is incorrect, because one of the strings in the sequence might contain characters which have special meaning inside a regular expression. Combinators avoid this problem by building a regular expression syntax tree directly, without any parsing." ; ARTICLE: "regexp.combinators" "Regular expression combinators" "The " { $vocab-link "regexp.combinators" } " vocabulary defines combinators which can be used to build up regular expressions to match strings. This complements the traditional syntax defined in the " { $vocab-link "regexp" } " vocabulary." { $subsections "regexp.combinators.intro" } "Basic combinators:" { $subsections } "Higher-order combinators for building new regular expressions from existing ones:" { $subsections } "Derived combinators implemented in terms of the above:" { $subsections } "Setting options:" { $subsections