package js_of_ocaml

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Js_of_ocaml.RegexpSource

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.

Sourcetype regexp

The type for regexps.

Sourcetype result

The type for match result.

Constructors

Sourceval regexp : string -> regexp

Simple regexp constructor.

Sourceval regexp_case_fold : string -> regexp

Same as regexp but matching will be performed in a case insensitive way.

Sourceval 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).

Sourceval quote : string -> string

Escapes characters with special meaning in the regexp context.

Sourceval regexp_string : string -> regexp

regexp_string s creates a regexp matching the exact string s.

Sourceval regexp_string_case_fold : string -> regexp

Same as regexp_string but matching will be performed in a case insensitive way.

Functions

Sourceval string_match : regexp -> string -> int -> result option

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.

Sourceval search_forward : regexp -> string -> int -> (int * result) option

Same as search.

Sourceval matched_string : result -> string

matched_string r return the exact substring that matched when evaluating r.

Sourceval matched_group : result -> int -> string option

matched_group r i is the ith group matched. Groups in matches are * obtained with parentheses. Groups are 1-based.

Sourceval global_replace : regexp -> string -> string -> string

global_replace r s by replaces all of the matches of r in s by by.

Sourceval replace_first : regexp -> string -> string -> string

replace_first r s by replaces the first match of r in s by by.

Sourceval split : regexp -> string -> string list

split r s splits the string s erasing matches with r. split (regexp " ") "toto tutu tata" is ["toto";"tutu";"tata"].

Sourceval bounded_split : regexp -> string -> int -> string list

bounded_split r s i is like split r s except that the result's length is less than i.

OCaml

Innovation. Community. Security.