Module Js_of_ocaml.Regexp
Types for regexps.
val regexp : string -> regexp
Simple regexp constructor.
val regexp_case_fold : string -> regexp
Same as
regexp
but matching will be performed in a case insensitive way.
val regexp_with_flag : string -> string -> regexp
Regexp constructor with flag that allow for case-insensitive search or multiline search (the global flag is always set).
val regexp_string : string -> regexp
regexp_string s
creates a regexp matching the exact strings
.
val regexp_string_case_fold : string -> regexp
Same as
regexp_string
but matching will be performed in a case insensitive way.
val string_match : regexp -> string -> int -> result option
string_match r s i
matches the strings
starting from thei
th character. Evaluates toNone
ifs
(from thei
th character) doesn't matchr
.
val search : regexp -> string -> int -> (int * result) option
search r s i
evaluates to the index of the match and the match result orNone
ifs
(starting fromi
) doesn't matchr
.
val matched_string : result -> string
matched_string r
return the exact substring that matched when evaluatingr
.
val matched_group : result -> int -> string option
matched_group r i
is thei
th group matched. Groups in matches are * obtained with parentheses. Groups are 1-based.
val global_replace : regexp -> string -> string -> string
global_replace r s by
replaces all of the matches ofr
ins
byby
.
val replace_first : regexp -> string -> string -> string
replace_first r s by
replaces the first match ofr
ins
byby
.
val split : regexp -> string -> string list
split r s
splits the strings
erasing matches withr
.split (regexp " ") "toto tutu tata"
is["toto";"tutu";"tata"]
.
val bounded_split : regexp -> string -> int -> string list
bounded_split r s i
is likesplit r s
except that the result's length is less thani
.