package dune-private-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=8f77d3a87f208e0d7cccaa1c48c4bb1bb87d62d07c3f25e9b8ba298e028ce52b
sha512=f209f12ced10c1abf8782bdb0143f4cec77795f7174d2cc75130afb1e01550b01f2f77b9e3ec4888efdad83d2f9878d179b39126f824f4e522f3ef4da34bf27e
doc/dune-private-libs.dune_re/Dune_re/index.html
Module Dune_re
Module Re
: regular expressions commons
Compilation and execution of a regular expression
Compile a regular expression into an executable version that can be used to match strings, e.g. with exec
.
exec re str
matches str
against the compiled expression re
, and returns the matched groups if any.
Similar to exec
, but returns an option instead of using an exception.
val execp : ?pos:int -> ?len:int -> re -> string -> bool
Similar to exec
, but returns true
if the expression matches, and false
if it doesn't
val exec_partial :
?pos:int ->
?len:int ->
re ->
string ->
[ `Full | `Partial | `Mismatch ]
More detailed version of exec_p
module Group : sig ... end
Manipulate matching groups.
module Mark : sig ... end
Marks
High Level Operations
Repeatedly calls exec
on the given string, starting at given position and length.
Same as all
but returns a generator
val matches : ?pos:int -> ?len:int -> re -> string -> string list
Same as all
, but extracts the matched substring rather than returning the whole group. This basically iterates over matched strings
Same as matches
, but returns a generator.
val split : ?pos:int -> ?len:int -> re -> string -> string list
split re s
splits s
into chunks separated by re
. It yields the chunks themselves, not the separator. For instance this can be used with a whitespace-matching re such as "[\t ]+"
.
val split_full : ?pos:int -> ?len:int -> re -> string -> split_token list
val split_full_gen : ?pos:int -> ?len:int -> re -> string -> split_token gen
replace ~all re ~f s
iterates on s
, and replaces every occurrence of re
with f substring
where substring
is the current match. If all = false
, then only the first occurrence of re
is replaced.
val replace_string :
?pos:int ->
?len:int ->
?all:bool ->
re ->
by:string ->
string ->
string
replace_string ~all re ~by s
iterates on s
, and replaces every occurrence of re
with by
. If all = false
, then only the first occurrence of re
is replaced.
String expressions (literal match)
val str : string -> t
val char : char -> t
Basic operations on regular expressions
val empty : t
Match nothing
val epsilon : t
Empty word
repn re i j
matches re
at least i
times and at most j
times, bounds included. j = None
means no upper bound.
String, line, word
val bol : t
Beginning of line
val eol : t
End of line
val bow : t
Beginning of word
val eow : t
End of word
val bos : t
Beginning of string
val eos : t
End of string
val leol : t
Last end of line or end of string
val start : t
Initial position
val stop : t
Final position
val not_boundary : t
Not at a word boundary
Match semantics
Repeated match modifiers
Groups (or submatches)
when matching against nest e
, only the group matching in the last match of e will be considered as matching
Mark a regexp. the markid can then be used to know if this regexp was used.
Character sets
val set : string -> t
Any character of the string
val rg : char -> char -> t
Character ranges
Predefined character sets
val any : t
Any character
val notnl : t
Any character but a newline
val alnum : t
val wordc : t
val alpha : t
val ascii : t
val blank : t
val cntrl : t
val digit : t
val graph : t
val lower : t
val print : t
val punct : t
val space : t
val upper : t
val xdigit : t
Case modifiers
Internal debugging
val pp : Format.formatter -> t -> unit
val pp_re : Format.formatter -> re -> unit
val print_re : Format.formatter -> re -> unit
Alias for pp_re
. Deprecated
Experimental functions
.
val witness : t -> string
witness r
generates a string s
such that execp (compile r) s
is true
Deprecated functions
val get_ofs : Group.t -> int -> int * int
Same as Group.offset
. Deprecated
val get_all_ofs : Group.t -> (int * int) array
Same as Group.all_offset
. Deprecated
val test : Group.t -> int -> bool
Same as Group.test
. Deprecated
val mark_set : Group.t -> Mark.Set.t
Same as Mark.all
. Deprecated
- Compilation and execution of a regular expression
- High Level Operations
- String expressions (literal match)
- Basic operations on regular expressions
- String, line, word
- Match semantics
- Repeated match modifiers
- Groups (or submatches)
- Character sets
- Predefined character sets
- Case modifiers
- Internal debugging
- Experimental functions
- Deprecated functions