package re
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d9674725760f926c6f4687bc8d449d6db8f839551a6ecc5288c923eaf018695b
md5=d2a74ca77216861bce4449600a132de9
doc/re/Re/index.html
Module Re
Source
Module Re
: regular expressions commons
Regular expression
Compiled regular expression
Information about groups in a match.
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.
Similar to exec
, but returns true
if the expression matches, and false
if it doesn't
More detailed version of exec_p
High Level Operations
Repeatedly calls exec
on the given string, starting at given position and length.
Same as all
but returns a generator
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.
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 replace :
?pos:int ->
?len:int ->
?all:bool ->
re ->
f:(Group.t -> string) ->
string ->
string
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.
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)
Basic operations on regular expressions
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
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
Predefined character sets
Case modifiers
Internal debugging
Alias for pp_re
. Deprecated
Experimental functions
.
Deprecated functions
Same as Group.offset
. Deprecated
Same as Group.all_offset
. Deprecated
Same as Group.test
. Deprecated
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