32 lines
812 B
C++
32 lines
812 B
C++
|
#include <iostream>
|
||
|
#include <regex>
|
||
|
#include <string>
|
||
|
|
||
|
class TagRemover {
|
||
|
private:
|
||
|
std::string content;
|
||
|
|
||
|
public:
|
||
|
TagRemover(std::istream& input) {
|
||
|
std::string line;
|
||
|
while (std::getline(input, line)) {
|
||
|
content += line + '\n';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void print(std::ostream& output) const {
|
||
|
std::string result = std::regex_replace(content, std::regex("<[^>]*>"), "");
|
||
|
result = std::regex_replace(result, std::regex("<"), "<");
|
||
|
result = std::regex_replace(result, std::regex(">"), ">");
|
||
|
result = std::regex_replace(result, std::regex(" "), " ");
|
||
|
result = std::regex_replace(result, std::regex("&"), "&");
|
||
|
|
||
|
output << result;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
int main() {
|
||
|
TagRemover tr(std::cin);
|
||
|
tr.print(std::cout);
|
||
|
return 0;
|
||
|
}
|