Function voca_rs::query::matches

source ·
pub fn matches(subject: &str, pattern: &str, position: usize) -> bool
Expand description

Checks whether subject matches the regular expression pattern. NOTE: Executes regular expressions only on valid UTF-8 while exposing match locations as byte indices into the search string (see case #4).

Arguments

  • subject - The string to verify.
  • pattern - The RegExp pattern to match, it is transformed to Regex::new(pattern).
  • position - The position to start matching.

Example

use voca_rs::*;
query::matches("pluto", "a", 0);
// => false
query::matches("pluto", r"plu.{2}", 0);
// => true
query::matches("apollo 11", r"\d{3}", 0);
// => false
query::matches("Zażółć gęślą jaźń", "gęślą", 11);
// => true (because "gęślą" starts from 11 not 7)
use voca_rs::Voca;
"pluto"._matches(r"plu.{2}", 0);
// => true