expression
Whole-input anchors
Anchor both ends when checking an entire input. This example accepts a restricted three-letter ASCII identifier, not a general account name policy. This example uses the external regex crate; see the staged Cargo manifest. Expected stdout (not executed): true false false Common mistake: Using an unanchored search to validate a complete value.
Formal Syntax & Structure
rust syntaxrust
\Apattern\zWorking Example
Example Snippetrust
fn main() { let re = regex::Regex::new(r"\A[A-Z]{3}\z").unwrap(); for text in ["ABC", "xABC", "ABC\n"] { println!("{}", re.is_match(text)); }}