Regex Tester for Rust
Free online regex tester with Rust code examples
Working with regex tester in Rust? Our free online regex tester helps Rust developers format, validate, and process data instantly. Below you will find Rust code examples using regex so you can achieve the same result programmatically in your own projects.
Try the Regex Tester Online
Use our free Regex Tester directly in your browser — no setup required.
Open Regex TesterRust Code Example
use regex::Regex;
fn main() {
let text = "Contact support@example.com";
let re = Regex::new(r"[\w.+-]+@[\w-]+\.[\w.]+").unwrap();
for cap in re.find_iter(text) {
println!("{}", cap.as_str());
}
}Quick Setup
Library: regex
cargo add regexRust Tips & Best Practices
- Use r"..." raw strings to avoid escaping backslashes
- Compile regex once with lazy_static! or std::sync::OnceLock
- The regex crate guarantees linear time matching