Rust Regex : Not Iterating through Str and capturing matches

hello rustaceans, please i need help. Have not being able to solve this after almost a day + trying.

let re = Regex::new(r"^([a-z0-9_+]([a-z0-9_+.]*[a-z0-9_+])?)@([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6})").unwrap();

let  email="The efi and ang gave me";
for element in re.captures_iter(email) {

This is returning empty vector. If email is just one email, it return the email but after adding more, it's not iterating through the string and finding the correct match and print.

I don't know what I'm doing wrongly

Your regex can be matched only at the beginning of input, due to the ^ sign. Drop it, and in your case all three emails will be matched.

1 Like

thanks, it work :face_with_hand_over_mouth:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.