We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Just a little comment on the Regex for anyone interested. The constraint given about the email addresses says "Each of the email IDs consists of lower case letters [a-z], @ and . only". Based on this definition, a better regex is "^[a-z\.]+@gmail\.com$".
Explanation: The ^ at the start is an anchor (so nothing is allowed to come before it), then [a-z\.] includes the lower case letters and . and the + means anything in that group 1 or more times.
Edit: You'll need to use two slashes where it's showing one.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 28: RegEx, Patterns, and Intro to Databases
You are viewing a single comment's thread. Return to all comments →
Just a little comment on the Regex for anyone interested. The constraint given about the email addresses says "Each of the email IDs consists of lower case letters [a-z], @ and . only". Based on this definition, a better regex is "^[a-z\.]+@gmail\.com$".
Explanation: The ^ at the start is an anchor (so nothing is allowed to come before it), then [a-z\.] includes the lower case letters and . and the + means anything in that group 1 or more times.
Edit: You'll need to use two slashes where it's showing one.