RustRegex

Documentation for RustRegex.

RustRegex.RuIteratorType
RuIterator(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")
source
RustRegex.RuRegexType
RuRegex(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

source
RustRegex.RuRegexMatchType
RuRegexMatch

A type representing a single match to a RuRegex found in a string, usually created from match.

The semantic is the same as RegexMatch.

source
RustRegex.capture_namesMethod
capture_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
source
RustRegex.@rure_strMacro
@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

source