Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/urlpattern/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  regexp.rs

  Sprache: Rust
 

use crate::parser::RegexSyntax;

pub trait RegExp: Sized {
  fn syntax() -> RegexSyntax;

  /// Generates a regexp pattern for the given string. If the pattern is
  /// invalid, the parse function should return an error.
  #[allow(clippy::result_unit_err)]
  fn parse(pattern: &str, flags: &str, force_eval: bool) -> Result<Self, ()>;

  /// Matches the given text against the regular expression and returns the list
  /// of captures. The matches are returned in the order they appear in the
  /// regular expression. It is **not** prefixed with the full match. For groups
  /// that occur in the regular expression, but did not match, the corresponding
  /// capture should be `None`.
  ///
  /// Returns `None` if the text does not match the regular expression.
  fn matches<'a>(&self, text: &'a str) -> Option<Vec<Option<&'a str>>>;

  fn pattern_string(&self) -> &str;
}

impl RegExp for regex::Regex {
  fn syntax() -> RegexSyntax {
    RegexSyntax::Rust
  }

  fn parse(pattern: &str, _flags: &str, _force_eval: bool) -> Result<Self, ()> {
    regex::Regex::new(pattern).map_err(|_| ())
  }

  fn matches<'a>(&self, text: &'a str) -> Option<Vec<Option<&'a str>>> {
    let captures = self.captures(text)?;

    let captures = captures
      .iter()
      .skip(1)
      .map(|c| c.map(|m| m.as_str()))
      .collect();

    Some(captures)
  }

  fn pattern_string(&self) -> &str {
    self.as_str()
  }
}

Messung V0.5 in Prozent
C=78 H=90 G=83

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.