package ecaml
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=87e76473915e12d718096100a5c4d15d98aba6f99ecbf21814b7389e8c28bb25
doc/ecaml/Ecaml/Regexp/index.html
Module Ecaml.Regexp
Source
A "regular expression", or "regexp" for short, is a pattern that denotes a (possibly infinite) set of strings.
(Info-goto-node "(elisp)Regular Expressions")
type t
is lazy. Construction functions (of_rx
, quote
, ...) don't construct the Emacs regexp until it is needed. Idiomatic use of a Regexp.t
looks like:
let some_function =
let regexp = Regexp.of_rx ... in
fun a b c ->
... Regexp.match_ regexp ...
This idiom only constructs the Emacs regexp when it is needed, and avoids reconstructing it every time it is used.
Rx.t
is the preferred way to construct regexps, especially when the alternative involves string manipulation in OCaml. of_rx
is lazy, and doesn't construct the Emacs regexp until it is needed.
any_pattern
is lazy, and doesn't construct the Emacs regexp until it is needed.
quote string
matches string
and nothing else. quote
is lazy, and doesn't construct the Emacs regexp until it is needed. (describe-function 'regexp-quote)
(Info-goto-node "(elisp)Regexp Functions")
any_quote strings
matches every string in strings
, and nothing else. any_quote
is lazy, and doesn't construct the Emacs regexp until it is needed. (describe-function 'regexp-opt)
(Info-goto-node "(elisp)Regexp Functions")
Supplying ~update_last_match:true
to a searching function causes Emacs to keep track of the "last match", i.e. the start and end positions of the segments of text found during the search. One can access parts of the last match via the Last_match
functions. subexp
is one based. (Info-goto-node "(elisp)Match Data")
match_ t text
finds the first match of t
in text
, returns the index of the start of the match. (describe-function 'string-match)
(describe-function 'string-match-p)
(Info-goto-node "(elisp)Regexp Search")
does_match t text
is is_some (match_ t text)
(describe-function 'replace-regexp-in-string)
(describe-function 'save-match-data)