Struct pcre::Pcre [] [src]

pub struct Pcre { /* fields omitted */ }

Wrapper for libpcre's pcre object (representing a compiled regular expression).

Methods

impl Pcre
[src]

Compiles the given regular expression.

Argument

  • pattern - The regular expression.

Compiles a regular expression using the given bitwise-OR'd options options.

Arguments

  • pattern - The regular expression.
  • options - Bitwise-OR'd compilation options. See the libpcre manpages, man 3 pcre_compile, for more information.

Returns the number of capture groups in the regular expression, including one for each named capture group.

This count does not include "group 0", which is the full substring within a subject string that matches the regular expression.

See also

  • name_count() - Returns the number of named capture groups.

Enables the use of the mark field when matching the compiled regular expression. The pattern must have been previously studied and an extra block must have been created.

To ensure that an extra block has been created, call study_with_options() passing the StudyExtraNeeded study option.

Return value

true if the use of the mark field could be enabled. false otherwise, which signifies that an extra block needs to be created.

Returns the extra block, if one has been created.

Matches the compiled regular expression against a given subject string subject. If no match is found, then None is returned. Otherwise, a Match object is returned which provides access to the captured substrings as slices of the subject string.

Argument

  • subject - The subject string.

Performance notes

This method is intended to be used to find individual matches. If multiple matches are desired, then a MatchIterator should be used because it is more efficient.

If a regular expression will be used often, it might be worth studying it to possibly speed up matching. See the study() method.

Matches the compiled regular expression against a given subject string subject starting at offset startoffset within the subject string. If no match is found, then None is returned. Otherwise, a Match object is returned which provides access to the captured substrings as slices of the subject string.

Arguments

  • subject - The subject string.
  • startoffset - Starting offset within subject at which to begin looking for a match.

Performance notes

This method is intended to be used to find individual matches. If multiple matches are desired, then a MatchIterator should be used because it is more efficient.

If a regular expression will be used often, it might be worth studying it to possibly speed up matching. See the study() method.

Matches the compiled regular expression against a given subject string subject starting at offset startoffset within the subject string and using the given bitwise-OR'd matching options options. If no match is found, then None is returned. Otherwise, a Match object is returned which provides access to the captured substrings as slices of the subject string.

Arguments

  • subject - The subject string.
  • startoffset - Starting offset within subject at which to begin looking for a match.
  • options - Bitwise-OR'd matching options. See the libpcre manpages, man 3 pcre_exec, for more information.

Performance notes

This method is intended to be used to find individual matches. If multiple matches are desired, then a MatchIterator should be used because it is more efficient.

If a regular expression will be used often, it might be worth studying it to possibly speed up matching. See the study() method.

Returns the mark name from PCRE if set.

Return value

Some(str) if PCRE returned a value for the mark. None if either there was no mark set or enable_mark() was not called, or was unsuccessful.

Returns the mark name from PCRE if set.

Return value

Some(&[u8]) if PCRE returned a value for the mark. None if either there was no mark set or enable_mark() was not called, or was unsuccessful.

Creates a MatchIterator for iterating through matches within the given subject string subject.

Argument

  • subject - The subject string.

Creates a MatchIterator for iterating through matches within the given subject string subject using the given bitwise-OR'd matching options options.

Arguments

  • subject - The subject string.
  • options - Bitwise-OR'd matching options. See the libpcre manpages, man 3 pcre_exec, for more information.

Returns the number of named capture groups in the regular expression.

Creates a name-to-number translation table that maps the name of each named capture group to the assigned group numbers.

The value type of the returned BTreeMap is a usize vector because there can be more than one group number for a given name if the PCRE_DUPNAMES option is used when compiling the regular expression.

Studies the regular expression to see if additional information can be extracted which might speed up matching.

Return value

true if additional information could be extracted. false otherwise.

Studies the regular expression using the given bitwise-OR'd study options options to see if additional information can be extracted which might speed up matching.

Argument

  • options - Study options. See the libpcre manpages, man 3 pcre_study, for more information about each option.

Return value

true if additional information could be extracted or the StudyExtraNeeded option was passed. false otherwise.

Trait Implementations

impl Debug for Pcre
[src]

Formats the value using the given formatter.

impl Drop for Pcre
[src]

A method called when the value goes out of scope. Read more