Module OnigurumaSource

Bindings to K.Kosako's Oniguruma library. Also see the Oniguruma API documentation.

Sourcetype _ t

A regular expression. The phantom type parameter indicates the encoding, so that regular expressions for different encodings may not be mixed.

Sourcetype 'enc regex = 'enc t

Alias for t. Useful when working with existential regex collections (for example RegSet).

Sourceexception Error of string

The exception raised upon Oniguruma errors.

Sourcemodule Encoding : sig ... end

Character encodings.

Sourcemodule Options : sig ... end

Regex options.

Sourcemodule Syntax : sig ... end

The syntax type.

Sourcemodule Region : sig ... end

Match results.

Sourcemodule MatchParam : sig ... end

Per-call match parameters.

Sourcemodule RegSet : sig ... end
Sourceval create : string -> Options.compile_time Options.t -> 'enc Encoding.t -> Syntax.t -> ('enc t, string) result

create pattern options encoding syntax creates a regex.

search regex string start range option searches String.sub string start range for regex. Raises Error if there is an error (other than a mismatch).

  • parameter regex

    The pattern to search for

  • parameter string

    The string to search

  • parameter start

    The string position to start searching from, as a byte offset

  • parameter range

    The string position to stop searching at, as a byte offset

  • parameter option

    Search options

Sourceval match_ : 'enc t -> string -> int -> Options.search_time Options.t -> Region.t option

match_ regex string pos options matches regex against string at position pos. Raises Error if there is an error (other than a mismatch).

  • parameter regex

    The pattern to match

  • parameter string

    The string to match against

  • parameter pos

    The position of the string to match at, as a byte offset

  • parameter options

    Match options

Sourceval search_with_param : 'enc t -> string -> int -> int -> Options.search_time Options.t -> MatchParam.t -> Region.t option

Like search but with per-call match parameters.

Sourceval match_with_param : 'enc t -> string -> int -> Options.search_time Options.t -> MatchParam.t -> Region.t option

Like match_ but with per-call match parameters.

Sourceval scan : _ t -> string -> Options.search_time Options.t -> (int -> int -> Region.t -> bool) -> int

scan regex string options callback finds all non-overlapping matches of regex in string. For each match, callback count pos region is called where count is the 1-based match number and pos is the byte offset. Return true from callback to continue scanning, false to stop. Returns the number of matches found.

Sourceval num_captures : _ t -> int

The number of capture groups in the regex. The entire match itself does not count as a capture group.

Sourceval name_to_group_numbers : _ t -> string -> int array

name_to_group_numbers regex name is the group number array of name in regex.

Sourceval number_of_names : _ t -> int

The number of distinct named capture groups in the regex.

Sourceval number_of_capture_histories : _ t -> int

The number of capture histories in the regex.

Sourceval noname_group_capture_is_active : _ t -> bool

true if unnamed group captures are active for this regex. When Options.dont_capture_group is used with named groups present, this returns false.

Sourceval get_options : _ t -> Options.compile_time Options.t

The compile-time options the regex was created with.

Sourceval foreach_name : _ t -> (string -> int array -> bool) -> unit

foreach_name regex f calls f name group_numbers for each named capture group. Return true from f to continue iteration, false to stop early.

Sourceval name_to_backref_number : _ t -> string -> Region.t -> int

name_to_backref_number regex name region resolves a named capture to the specific group number that matched in region. Useful when multiple groups share a name. Raises Error if the name is not found.

Sourceval get_match_stack_limit_size : unit -> int
Sourceval set_match_stack_limit_size : int -> unit
Sourceval get_retry_limit_in_match : unit -> int
Sourceval set_retry_limit_in_match : int -> unit
Sourceval get_parse_depth_limit : unit -> int
Sourceval set_parse_depth_limit : int -> unit
Sourceval set_capture_num_limit : int -> unit
Sourceval get_subexp_call_max_nest_level : unit -> int
Sourceval set_subexp_call_max_nest_level : int -> unit
Sourceval version : string

The Oniguruma version string. This is the version of the underlying C library, not this OCaml binding library.