Struct oniguruma::Regex [] [src]

pub struct Regex {
    // some fields omitted
}

A compiled Oniguruma regular expression.

Methods

impl Regex

fn captures<'t>(&self, text: &'t str) -> Option<Captures<'t>>

Returns the capture groups corresponding to the leftmost-first match in text. Capture group 0 always corresponds to the entire match. If no match is found, then None is returned.

Panics

This method may panic in the case of memory overflow during execution or other internal errors of Oniguruma engine.

impl Regex

fn new(pattern: &str) -> Result<Regex, Error>

Compiles a regular expression with default options. Default syntax is SYNTAX_RUBY.

Once compiled, it can be used repeatedly to search in a string. If an invalid expression is given, then an error is returned.

fn new_with_config<'a>(pattern: &str, config: RegexConfig<'a>) -> Result<Regex, Error>

fn search_with_region(&self, text: &str, region: &mut Region, options: Options) -> Result<Option<usize>, Error>

Search pattern in string and store search result into region object.

Returns match position offset if pattern is found, otherwise return None. You also can use search time options: OPTION_NOTBOL and OPTION_NOTEOL.

fn match_with_region(&self, text: &str, region: &mut Region, options: Options) -> Result<Option<usize>, Error>

Match string and store search result into region object.

Returns match length if pattern is found, otherwise return None. You also can use search time options: OPTION_NOTBOL and OPTION_NOTEOL.

fn is_match(&self, text: &str) -> bool

Returns true if and only if the regex matches the string given.

Panics

This method may panic in the case of memory overflow during execution or other internal errors of Oniguruma engine.

fn find(&self, text: &str) -> Option<(usize, usize)>

Returns the start and end byte range of the leftmost-first match in text. If no match exists, then None is returned.

Note that this should only be used if you want to discover the position of the match. Testing the existence of a match is faster if you use is_match.

Panics

This method may panic in the case of memory overflow during execution or other internal errors of Oniguruma engine.

Trait Implementations

impl Drop for Regex

fn drop(&mut self)

Derived Implementations

impl Debug for Regex

fn fmt(&self, __arg_0: &mut Formatter) -> Result