package orsetto
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=9b654edb663ae697563f150824047052f3b1bf760398f24bce6350553f031f73c46b6337239a1acd871e61238597ea92046809e3358290ff14d6ba671b449085
doc/orsetto.cf/Cf_regx/index.html
Module Cf_regx
Regular expression parsing, search and matching.
Overview
This module implements simple regular expression parsing, search and matching in pure Objective Caml for 8-bit extended ASCII text.
Use any of the following constructions in regular expressions:
\nMatches LF ("newline") character.\tMatches TAB character.\rMatches RETURN character.\aMatches an alphabetical character.\dMatches a decimal digit character.\iMatches an alphanumerical character.\sMatches a TAB, LF, VT, FF, CR or SPACE (whitespace) character.\wMatches a character other than a whitespace character.\xNNMatches the character with hexadecimal codeNN.\DDDMatches the character with decimal codeDDD, where DDD is a three digit number between000and255.\c_Matches the control character corresponding to the subsequent printable character, e.g.\cAis CONTROL-A, and\c[is ESCAPE..Matches any character except newline.*(postfix) Matches the preceding expression, zero, one or several times in sequence.+(postfix) Matches the preceding expression, one or several times in sequence.?(postfix) Matches the preceding expression once or not at all.[..]Character set. Ranges are denoted with'-', as in[a-z]. An initial'^', as in[^0-9], complements the set. Special characters in the character set syntax may be included in the set by escaping them with a backtick, e.g.[`^```]]is a set containing three characters: the carat, the backtick and the right bracket characters.(..|..)Alternatives. Matches one of the expressions between the parentheses, which are separated by vertical bar characters.\_Escaped special character. The special characters are'\\','.','*','+','?','(','|',')','['.
Interface
module DFA : sig ... endThe deterministic finite automata on octet character symbols.
val of_string : string -> tUse of_string s to make a regular expression denoted by s. Raises Invalid_argment if s does not denote a valid regular expression.
Use of_chars s to make a regular expression denoted by the characters in s. Raises Invalid_argment if the characters do not denote a valid regular expression.
Use of_dfa_term s to make a regular expression for recognizing the language term s.
val test : t -> string -> boolUse test r s to test whether r recognizes s. Returns true if all the characters in s are not rejected and the DFA reaches at least one final state, otherwise returns false.
val contains : t -> string -> boolUse contains r s to test whether r recognizes any substring of s.
Use search r s to search with r in a confluently persistent sequence s for the first accepted subsequence. Returns None if s does not contain a matching subsequence. Otherwise, returns Some (start, limit) where start is the index of the first matching subsequence, and limit is the index after the end of the longest matching subsequence.
val split : t -> string Cf_slice.t -> string Cf_slice.t Seq.tUse split r s to split s into a sequence of slices comprising the substrings in s that are separated by disjoint substrings matching r, which are found by searching from left to right. If r does not match any substring in s, then a sequence containing just s is returned, even if s is an empty slice.
Use quote s to make a copy of s by converting all the special characters into escape sequences.