Legend:
Library
Module
Module type
Parameter
Class
Class type
Wrapper for regexps with Str syntax * * This module was written at a time when we had only the Str module * for regular expressions. However, Str has an interface that does * not work for multi-threaded programs, because the state of the module * is visible to the outside. The module Netstring_str is similar to Str, * but has a thread-compatible interface. * * For an explanation why we need this module, please read Regexp.
Supported regexp syntax * *
* . matches every character but newline
* e* matches e several times
* e+ matches e several times but at least once
* e? matches e optionally
* e{m,n} matches e at least m times and at most n times
* e1\|e2 matches e1 or e2
* [set] matches the characters from set
* [^set] matches the characters except from set
* \(...\) group paranthesis
* \n back reference (n is digit)
* ^ matches at beginning of line
* $ matches at end of line
*
* * This is exactly what Str supports. Character classes * are not implemented.
Returns a case-insensitive regexp that matches exactly the string
val quote_set : string -> string
Returns a regexp (as string) that matches any of the characters in the argument. The argument must be non-empty
val string_match : regexp->string ->int ->result option
Matches the string at the position with the regexp. Returns * None if no match is found. Returns Some r on success, * and r describes the match.
val bytes_match : regexp->Stdlib.Bytes.t ->int ->result option
Same for bytes
val search_forward : regexp->string ->int -> int * result
Searches a match of the string with the regexp, starting at * the position and in forward direction. * Raises Not_found if no match could be found. * Returns (p,r) when a match at position p is found, * described by r.
val search_forward_bytes : regexp->Stdlib.Bytes.t ->int -> int * result
Same for bytes
val search_backward : regexp->string ->int -> int * result
Searches a match of the string with the regexp, starting at * the position and in backward direction. * Raises Not_found if no match could be found. * Returns (p,r) when a match at position p is found, * described by r.
val search_backward_bytes : regexp->Stdlib.Bytes.t ->int -> int * result
Extracts the matched part from the string. The string argument * must be the same string passed to string_match or the search * functions, and the result argument must be the corresponding * result.
val matched_bytes : result->Stdlib.Bytes.t ->Stdlib.Bytes.t
val matched_group : result->int ->string -> string
Extracts the substring the nth group matches from the whole * string. The string argument * must be the same string passed to string_match or the search * functions, and the result argument must be the corresponding * result.
val matched_group_bytes : result->int ->Stdlib.Bytes.t ->Stdlib.Bytes.t
Returns the position where the substring matching the nth * group ends
val global_replace : regexp->string ->string -> string
global_replace re templ s: Replaces all matchings of re in * s by templ. * * In templ one can refer to matched groups by the backslash notation: * \1 refers to the first group, \2 to the second etc. * \0 is the whole match. \\ is the backslash character.
val replace_first : regexp->string ->string -> string
replace_first re templ s: Replaces the first match of re in * s by templ. * * In templ one can refer to matched groups by the backslash notation: * \1 refers to the first group, \2 to the second etc. * \0 is the whole match. \\ is the backslash character.
val global_substitute :
regexp->(result->string -> string)->string ->
string
global_substitute re subst s: Applies the substitution function * subst to all matchings of re in s, and returns the * transformed string. subst is called with the current result * of the match and the whole string s.
val substitute_first :
regexp->(result->string -> string)->string ->
string
substitute_first re subst s: Applies the substitution function * subst to the first matching of re in s, and returns the * transformed string. subst is called with the current result * of the match and the whole string s.