expression
Unicode digits versus ASCII digits
In the default Unicode-aware string engine, the digit class includes decimal digits from multiple writing systems. An ASCII-only protocol can use an explicit ASCII range. This example uses the external regex crate; see the staged Cargo manifest. Expected stdout (not executed): true false Common mistake: Assuming the Unicode digit class is the same as ASCII numeric input.
Formal Syntax & Structure
rust syntaxrust
\d versus [0-9]Working Example
Example Snippetrust
fn main() { let unicode = regex::Regex::new(r"\A\d+\z").unwrap(); let ascii = regex::Regex::new(r"\A[0-9]+\z").unwrap(); println!("{} {}", unicode.is_match("۱۲۳"), ascii.is_match("۱۲۳"));}