pub struct RegexAnalyzer;Expand description
Analysis utilities for Perl regex patterns: capture extraction and hover text.
Implementations§
Source§impl RegexAnalyzer
impl RegexAnalyzer
Sourcepub fn extract_named_captures(pattern: &str) -> Vec<CaptureGroup>
pub fn extract_named_captures(pattern: &str) -> Vec<CaptureGroup>
Extract all named capture groups from a Perl regex pattern.
Scans the pattern for (?<name>...) groups and returns them in left-to-right
order. Non-capturing groups ((?:...)), lookaheads, and lookbehinds do not
increment the capture index. Escaped parentheses (\() are skipped.
§Example
use perl_regex::RegexAnalyzer;
let caps = RegexAnalyzer::extract_named_captures("(?<year>\\d{4})-(?<month>\\d{2})");
assert_eq!(caps.len(), 2);
assert_eq!(caps[0].name, "year");
assert_eq!(caps[0].index, 1);Sourcepub fn hover_text_for_regex(pattern: &str, modifiers: &str) -> String
pub fn hover_text_for_regex(pattern: &str, modifiers: &str) -> String
Generate hover text for a Perl regex pattern and its modifiers.
Summarises the named capture groups and explains the meaning of each
modifier flag (i, m, s, x, g).
§Example
use perl_regex::RegexAnalyzer;
let text = RegexAnalyzer::hover_text_for_regex("(?<id>\\d+)", "i");
assert!(text.contains("id"));
assert!(text.contains("case"));Auto Trait Implementations§
impl Freeze for RegexAnalyzer
impl RefUnwindSafe for RegexAnalyzer
impl Send for RegexAnalyzer
impl Sync for RegexAnalyzer
impl Unpin for RegexAnalyzer
impl UnsafeUnpin for RegexAnalyzer
impl UnwindSafe for RegexAnalyzer
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