You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks you for this project, I am a new one study rust, I use this lib have some problem.
regex version
1.10.3
code
use regex::Regex;
#[test]
fn test_is_email() {
// let a = is_email(&"[email protected]".to_string());
// assert_eq!(a, true);
let r = Regex::new(r"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$").unwrap();
let aa = r.is_match("[email protected]");
assert_eq!(aa,true)
}
The output in termainal
running 1 test
thread 'tests::form_test::test_is_email' panicked at src/tests/form_test.rs:9:61:
called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
^^
error: invalid range boundary, must be a literal
The text was updated successfully, but these errors were encountered:
The regex is not valid. The error message is both telling you the problem and pointing you to where it occurs. A - in a character class indicates a range. Both sides of a range must be a literal character (or absent, i.e., adjacent to the open or close of a class as in [\w-]), but \w is itself another character class. You likely either want [\w\-.] or [-\w.]. Incidentally, your escaping of . inside a character class is superfluous because a . has no special meaning inside of a class.
Thanks for your work
Thanks you for this project, I am a new one study rust, I use this lib have some problem.
regex version
1.10.3
code
The output in termainal
The text was updated successfully, but these errors were encountered: