gossamer/regexp
Types
The result of exec.
valueis the matched substring (the full match, group 0).capturescontains the numbered capture groups, group 1 onwards.Noneindicates a group that didn’t match.named_capturescontains only the named groups that matched.indexis the 0-based position of the match in the input.
Match-level indices data from the HasIndices flag is not
currently exposed.
pub type Match {
Match(
value: String,
captures: List(option.Option(String)),
named_captures: dict.Dict(String, String),
index: Int,
)
}
Constructors
-
Match( value: String, captures: List(option.Option(String)), named_captures: dict.Dict(String, String), index: Int, )
Values
pub fn escape(string: String) -> String
Escapes string so it can be safely embedded in a regex pattern as
a literal substring.
pub fn exec(
regex: RegExp,
against input: String,
) -> Result(Match, Nil)
Returns the next match of regex in input, or an error if no
match. With the Global or Sticky flag, advances last_index.
pub fn flags(of regex: RegExp) -> List(regexp_flag.RegExpFlag)
The flags of regex in canonical order (alphabetical by flag
character).
pub fn has_indices(of regex: RegExp) -> Bool
pub fn is_dot_all(of regex: RegExp) -> Bool
pub fn is_ignore_case(of regex: RegExp) -> Bool
pub fn is_multiline(of regex: RegExp) -> Bool
pub fn is_unicode(of regex: RegExp) -> Bool
pub fn is_unicode_sets(of regex: RegExp) -> Bool
pub fn last_index(of regex: RegExp) -> Int
The position at which the next exec will start matching, when the
regex has the Global or Sticky flag.
pub fn new(pattern: String) -> Result(RegExp, js_error.JsError)
Creates a new RegExp from pattern. Returns an error if the
pattern is not a valid regular expression.
pub fn new_with(
pattern: String,
with flags: List(regexp_flag.RegExpFlag),
) -> Result(RegExp, js_error.JsError)
Creates a new RegExp from pattern with the given flags. Returns
an error if the pattern is invalid or the flags are incompatible
(e.g., both Unicode and UnicodeSets).