| 82 | } |
| 83 | |
| 84 | std::string removeChars(const std::string& input, const std::string& chars) { |
| 85 | std::string result; |
| 86 | size_t prev = 0; |
| 87 | size_t pos = input.find_first_of(chars); |
| 88 | while (pos != std::string::npos) { |
| 89 | if (pos > prev) { |
| 90 | result += input.substr(prev, pos - prev); |
| 91 | } |
| 92 | prev = pos + 1; |
| 93 | pos = input.find_first_of(chars, prev); |
| 94 | } |
| 95 | pos = input.length(); |
| 96 | if (pos > prev) { |
| 97 | result += input.substr(prev, pos - prev); |
| 98 | } |
| 99 | return result; |
| 100 | } |
| 101 | |
| 102 | TEST(TestFileScan, testRemoveChars) { |
| 103 | EXPECT_EQ("abcdef", removeChars("abcdef", "xyz")); |