Module Js_of_ocaml.Regexp
Types for regexps.
Warning: the regexp syntax is the javascript one. It differs from the syntax used by the Str module from the OCaml standard library.
type regexpThe type for regexps.
type resultThe type for match result.
Constructors
val regexp : string -> regexpSimple regexp constructor.
val regexp_case_fold : string -> regexpSame as regexp but matching will be performed in a case insensitive way.
val regexp_with_flag : string -> string -> regexpRegexp constructor with flag that allow for case-insensitive search or multiline search (the global flag is always set).
val quote : string -> stringEscapes characters with special meaning in the regexp context.
val regexp_string : string -> regexpregexp_string s creates a regexp matching the exact string s.
val regexp_string_case_fold : string -> regexpSame as regexp_string but matching will be performed in a case insensitive way.
Functions
string_match r s i matches the string s starting from the ith character. Evaluates to None if s (from the ith character) doesn't match r.
search r s i evaluates to the index of the match and the match result or None if s (starting from i) doesn't match r.
val matched_string : result -> stringmatched_string r return the exact substring that matched when evaluating r.
val matched_group : result -> int -> string optionmatched_group r i is the ith group matched. Groups in matches are * obtained with parentheses and are 1-based; index 0 returns the whole * matched substring (as matched_string does).
val global_replace : regexp -> string -> string -> stringglobal_replace r s by replaces all of the matches of r in s by by.
val replace_first : regexp -> string -> string -> stringreplace_first r s by replaces the first match of r in s by by.
val split : regexp -> string -> string listsplit r s splits the string s erasing matches with r. split (regexp " ") "toto tutu tata" is ["toto";"tutu";"tata"].
val bounded_split : regexp -> string -> int -> string listbounded_split r s i is like split r s except that the result's length is less than i.