pub struct JsRegex { /* private fields */ }Expand description
A compiled JS regular expression.
Implementations§
Source§impl JsRegex
impl JsRegex
Sourcepub fn new(source: &str, flags: &str) -> JsRegex
pub fn new(source: &str, flags: &str) -> JsRegex
Compiles a JS pattern. Panics on an invalid pattern: patterns are constants, and every one is compiled by the unit tests of the module that owns it.
Sourcepub fn try_new(source: &str, flags: &str) -> Result<JsRegex, String>
pub fn try_new(source: &str, flags: &str) -> Result<JsRegex, String>
Compiled once per (source, flags) in the process: upstream builds new RegExp(...) inside
methods called on every parse (innerPattern()), and a ported step that does the same must not
recompile a Unicode case-insensitive pattern each time (ru/uk ran ~30x slower than other locales).
Sourcepub fn exec(&self, text: &str) -> Option<RegexMatch>
pub fn exec(&self, text: &str) -> Option<RegexMatch>
regex.exec(text) for a non-global regex: the first match, searching from the start.
A backtracking-limit error counts as “no match”.
Trait Implementations§
Auto Trait Implementations§
impl Forget for JsRegex
impl Freeze for JsRegex
impl RefUnwindSafe for JsRegex
impl Send for JsRegex
impl Sync for JsRegex
impl Unpin for JsRegex
impl UnsafeUnpin for JsRegex
impl UnwindSafe for JsRegex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more