Docs.rs
  • js-regexp-0.2.1
    • js-regexp 0.2.1
    • Permalink
    • Docs.rs crate page
    • MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • cyradotpink
    • Dependencies
      • js-regexp-macros ^0.2.1 normal
      • js-sys ^0.3.64 normal
      • wasm-bindgen ^0.2.87 normal
      • wasm-bindgen-test ^0.3.37 dev
    • Versions
    • 80% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate js_regexp

js_regexp0.2.1

  • All Items

Sections

  • Basic usage

Crate Items

  • Macros
  • Structs

Crates

  • js_regexp

Crate js_regexp

Source
Expand description

Ergonomic Rust bindings to the JavaScript standard built-in RegExp object

§Basic usage

use js_regexp::{flags, RegExp};

let mut re = RegExp::new(r#"(?<greeting>\w+), (?<name>\w+)"#, flags!("d")).unwrap();
let result = re.exec("Hello, Alice!").unwrap();

let mut iter = result.captures().unwrap().iter();
let named_captures = result.named_captures().unwrap();

assert_eq!("Hello, Alice", result.match_slice);
assert_eq!(0, result.match_index);
assert_eq!(12, result.match_length);
assert_eq!("Hello", iter.next().unwrap().slice);
assert_eq!("Hello", named_captures.get("greeting").unwrap().slice);
assert_eq!(5, iter.next().unwrap().length);
assert_eq!(7, named_captures.get("name").unwrap().index);

Macros§

flags
Checks validity of a flags string literal at compile time and inserts a therefore safe runtime call to Flags::new_unchecked.

Structs§

Capture
An index, length, slice, and optional group name of a capture in a haystack.
ExecResult
The result of a successful RegExp::exec call.
FlagSets
Boolean fields representing regular expression flags.
Flags
A checked interface for setting regular expression flags.
RegExp
A wrapped JavaScript RegExp. The main type of this crate.
RegExpStream
Repeatedly match in the same haystack using the same regular expression.

Results

Settings
Help
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.