Struct pica_record::matcher::subfield::RegexMatcher
source · pub struct RegexMatcher { /* private fields */ }
Expand description
A matcher that checks a subfield value against a regex.
Implementations§
source§impl RegexMatcher
impl RegexMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new RegexMatcher.
§Errors
This function fails if the given expression is not a valid regex matcher.
§Example
use pica_record::matcher::subfield::RegexMatcher;
let _matcher = RegexMatcher::new("0 =~ '^Tp'")?;
sourcepub fn is_match<'a>(
&self,
subfields: impl IntoIterator<Item = &'a SubfieldRef<'a>>,
options: &MatcherOptions,
) -> bool
pub fn is_match<'a>( &self, subfields: impl IntoIterator<Item = &'a SubfieldRef<'a>>, options: &MatcherOptions, ) -> bool
Returns true if at least one (ANY) or all (ALL) subfield values matches against the regular expression.
§Example
use pica_record::matcher::subfield::RegexMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let options = MatcherOptions::default();
let subfield = SubfieldRef::new('0', "Tp1")?;
let matcher = RegexMatcher::new("0 =~ '^Tp'")?;
assert!(matcher.is_match(&subfield, &options));
let matcher = RegexMatcher::new("0 !~ '^Ts'")?;
assert!(matcher.is_match(&subfield, &options));
Trait Implementations§
source§impl Clone for RegexMatcher
impl Clone for RegexMatcher
source§fn clone(&self) -> RegexMatcher
fn clone(&self) -> RegexMatcher
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RegexMatcher
impl Debug for RegexMatcher
source§impl Display for RegexMatcher
impl Display for RegexMatcher
source§impl PartialEq for RegexMatcher
impl PartialEq for RegexMatcher
impl StructuralPartialEq for RegexMatcher
Auto Trait Implementations§
impl Freeze for RegexMatcher
impl RefUnwindSafe for RegexMatcher
impl Send for RegexMatcher
impl Sync for RegexMatcher
impl Unpin for RegexMatcher
impl UnwindSafe for RegexMatcher
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)