module Netstring_pcre:sig..end
This module is a version of Str with a thread-safe interface,
implemented using Pcre.
This modules processes PCRE-style regular expressions. If you like
to write Str-like regexps, you can also use Netstring_str with
almost the same signature.
The functions in this module are unavailable if Ocamlnet is built
with Str as implementation of regular expressions! They will always
raise Invalid_argument!
typeregexp =Pcre.regexp
typesplit_result =Pcre.split_result=
| |
Text of |
| |
Delim of |
| |
Group of |
| |
NoGroup |
Pcretype result
Pcreval regexp : string -> regexpval regexp_case_fold : string -> regexpval quote : string -> stringval regexp_string : string -> regexpval regexp_string_case_fold : string -> regexpval string_match : regexp -> string -> int -> result optionval search_forward : regexp -> string -> int -> int * resultNone if no match is found. Returns Some r on success,
and r describes the match.val search_backward : regexp -> string -> int -> int * resultNot_found if no match could be found.
Returns (p,r) when a match at position p is found,
described by r.val matched_string : result -> string -> stringNot_found if no match could be found.
Returns (p,r) when a match at position p is found,
described by r.val match_beginning : result -> intstring_match or the search
functions, and the result argument must be the corresponding
result.val match_end : result -> intval matched_group : result -> int -> string -> stringval group_beginning : result -> int -> intstring_match or the search
functions, and the result argument must be the corresponding
result.val group_end : result -> int -> intval global_replace : regexp -> string -> string -> stringval replace_first : regexp -> string -> string -> stringglobal_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 global_substitute : regexp ->
(result -> string -> string) -> string -> stringreplace_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 substitute_first : regexp ->
(result -> string -> string) -> string -> stringglobal_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 split : regexp -> string -> string listsubstitute_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.val bounded_split : regexp -> string -> int -> string listval split_delim : regexp -> string -> string listn substrings, based on splitval bounded_split_delim : regexp -> string -> int -> string listsplit, but occurrences of the delimiter at the beginning
and the end are returned as empty stringsval full_split : regexp -> string -> split_result listn substrings, based on split_delimval bounded_full_split : regexp -> string -> int -> split_result listsplit_delim, but returns the delimiters in the resultval string_before : string -> int -> stringn substrings, based on full_splitval string_after : string -> int -> stringn characters of a stringval first_chars : string -> int -> stringn characters of a stringval last_chars : string -> int -> stringstring_before