RustRegex
Documentation for RustRegex.
RustRegex.RuIterator
RustRegex.RuRegex
RustRegex.RuRegexMatch
RustRegex.capture_names
RustRegex.has_captures
RustRegex.@rure_str
RustRegex.RuIterator
— TypeRuIterator(re::RuRegex, str::String; capture = false)
A iterator return each matched substring. By setting capture = true
, this is equivalent to eachmatch(re, str)
.
Example
julia> collect(RustRegex.RuIterator(rure"\w+", "a b c"))
3-element Vector{SubString{String}}:
"a"
"b"
"c"
julia> collect(RustRegex.RuIterator(rure"\w+", "a b c"; capture = true))
3-element Vector{RustRegex.RuRegexMatch}:
RuRegexMatch("a")
RuRegexMatch("b")
RuRegexMatch("c")
RustRegex.RuRegex
— TypeRuRegex(pattern[, flags]) <: AbstractPattern
A type representing rust regular expression. Some syntax and behavior might be different from PCRE regex. RuRegex
support occursin
, findnext
, findfirst
, findall
, replace
, split
, startswith
, endswith
, count
, match
, and eatchmatch
.
See also: @rure_str
RustRegex.RuRegexMatch
— TypeRuRegexMatch
A type representing a single match to a RuRegex
found in a string, usually created from match
.
The semantic is the same as RegexMatch
.
RustRegex.capture_names
— Methodcapture_names(re::RuRegex) -> Vector{Union{Int, String}}
Return capture name or index.
Example
julia> RustRegex.capture_names(rure"(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})")
3-element Vector{Union{Int64, String}}:
"year"
"month"
"day"
julia> RustRegex.capture_names(rure"(?<hour>\d+):(?<minute>\d+)(am|pm)?")
3-element Vector{Union{Int64, String}}:
"hour"
"minute"
3
RustRegex.has_captures
— Methodhas_captures(re::RuRegex) -> Bool
Return true if there are any capture groups in the regex.
RustRegex.@rure_str
— Macro@rure_str -> RuRegex
Construct a rust regex, such as rure"^[a-z]*$"
, without interpolation and unescaping (except for quotation mark "
which still has to be escaped). The regex also accepts one or more flags, listed after the ending quote:
- case insensitive (i) flag.
- multi-line matching (m) flag. (
^
and$
match new line boundaries.) - any character (s) flag. ("." matches new line.)
- greedy swap (U) flag. (e.g.,
+
is ungreedy and+?
is greedy.) - ignore whitespace (x) flag.
- Unicode (u) flag. (default flag)
See also: RuRegex