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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 28: RegEx, Patterns, and Intro to Databases
  5. Discussions

Day 28: RegEx, Patterns, and Intro to Databases

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

    You are viewing a single comment's thread. Return to all comments →

  • chethangowda
    6 years ago+ 10 comments

    In c++ using regex expressions, but you have to include <regex> header

    int main(){
    int N;
    cin >> N;
    regex e(".+@gmail\\.com$");
    vector<string> db;
    for(int a0 = 0; a0 < N; a0++){
    string firstName;
    string emailID;
    cin >> firstName >> emailID;
    if(regex_match(emailID,e)){
    db.push_back(firstName);
    }
    }
    sort(db.begin(),db.end());
    for(int i = 0;i < db.size();i++)
    {
    cout << db[i] << endl;
    }
    return 0;
    }
    35|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature