Николай Веселуха
Высший разум
(362058)
6 лет назад
#include <iostream>
#include <sstream>
#include <regex>
#include <string>
using namespace std;
string foo(const string& line) {
istringstream iss(line);
string box, word;
while (iss >> word) {
if (regex_match(word, regex(R"([a-zA-Z]+)"))) {
if (box.length()) box += ' ';
box += word;
}
}
return box;
}
int main() {
cout << "String? ";
string line;
getline(cin, line);
const auto str = foo(line);
cout << str << endl;
system("pause");
}