what is the proper regex to check for a gmail address
-
wrote on 17 Aug 2020, 11:55 last edited by Natural_Bugger
Hello,
i only need to check if it contains "gmail.com" after the @, anything before doesn't matter
i found various, but none did the job.
smatch match; regex r("gmail.com"); if(regex_search(iter->second, match, r)){ std::cout << iter->first << std::endl; }
this doesn't cut the mostard.
alice alice@alicegmail.com alice alice@gmail.com
regards.
-
And why in 'C++ Gurus'? Doing a simply QString::endsWidth() so hard to need a c++ guru?
-
Hello,
i only need to check if it contains "gmail.com" after the @, anything before doesn't matter
i found various, but none did the job.
smatch match; regex r("gmail.com"); if(regex_search(iter->second, match, r)){ std::cout << iter->first << std::endl; }
this doesn't cut the mostard.
alice alice@alicegmail.com alice alice@gmail.com
regards.
wrote on 17 Aug 2020, 11:56 last edited by JonB@Natural_Bugger
So did you try^.*@gmail\.com$
?Though as @Christian-Ehrlicher says, as stated by you it doesn't need a regular expression anyway.
-
@Natural_Bugger
So did you try^.*@gmail\.com$
?Though as @Christian-Ehrlicher says, as stated by you it doesn't need a regular expression anyway.
wrote on 17 Aug 2020, 12:05 last edited bythnks for your answer and it worked out.
haven't touched regex in years or decenia.that is the assignment, use regex.
-
And why in 'C++ Gurus'? Doing a simply QString::endsWidth() so hard to need a c++ guru?
wrote on 17 Aug 2020, 12:06 last edited bysorry, i didn't know what was the right section.
-
wrote on 17 Aug 2020, 17:23 last edited by
Please feel free to ignore me if I am "overthinking" the nature of your task...
I'm wondering why exactly anyone would filter precisely and exclusively "gmail.com" addresses. One answer that immediately comes to mind is the use case where you want to use Google OAuth. The user would (I believe) need a provided-by-google email account to participate in Google OAuth. However, filtering by "gmail.com" is overly restrictive for that case. When a business uses Google as their email provider, you can have "me@mybusiness.com" provided under-the-hood by Gmail.
1/6