Skip to main content

RegExpProvider

Trait RegExpProvider 

Source
pub trait RegExpProvider {
    // Required method
    fn compile(
        &self,
        pattern: &str,
        flags: &str,
    ) -> Result<Rc<dyn CompiledRegex>, String>;
}
Expand description

Trait for providing regex compilation functionality.

Implementations can wrap different regex engines:

  • FancyRegexProvider: Uses the fancy-regex crate (default for std builds)
  • WasmRegExpProvider: Delegates to browser’s native RegExp via wasm-bindgen
  • Custom C implementations via FFI callbacks

Required Methods§

Source

fn compile( &self, pattern: &str, flags: &str, ) -> Result<Rc<dyn CompiledRegex>, String>

Compile a regex pattern with the given flags.

§Flags
  • g: global (affects JS-level iteration, not compilation)
  • i: case-insensitive matching
  • m: multiline (^ and $ match line boundaries)
  • s: dotAll (. matches newlines)
  • u: unicode
  • y: sticky (match only at lastIndex)

Returns a compiled regex that can be used for matching operations.

Implementors§