Skip to content

Instantly share code, notes, and snippets.

@h2rashee
Created June 6, 2014 19:24
Show Gist options
  • Save h2rashee/b29e9feda6e295b6571d to your computer and use it in GitHub Desktop.
Save h2rashee/b29e9feda6e295b6571d to your computer and use it in GitHub Desktop.
Processes e-mail lists and extracts e-mails from: "Name" (Email); ...
#include <iostream>
#include <vector>
using namespace std;
vector<string> emails;
void printVector()
{
for(vector<string>::iterator it = emails.begin(); it != emails.end(); it++)
{
cout << *it << "; ";
}
cout << endl;
}
int main()
{
string input;
getline(cin, input);
int pos = 0;
while(input.find_first_of("(",pos) != string::npos)
{
string em;
int start = input.find_first_of("(",pos) + 1;
int end = input.find_first_of(")",pos);
em = input.substr(start, end-start);
emails.push_back(em);
pos = end + 1;
if(input.length() < pos)
{
break;
}
}
printVector();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment