Skip to content

Commit 684134e

Browse files
string_replace_if(replace_char_from_another_
1 parent 7238b92 commit 684134e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
#include <string>
3+
4+
//http://www.cplusplus.com/reference/algorithm/replace_if/
5+
6+
int main(){
7+
std::string mystr = "Hello! How is he? He's fine, he's good.;";
8+
std::string toRemove = "!?',;.";
9+
std::replace_if(mystr.begin(), mystr.end(),
10+
[toRemove](char c) { return toRemove.find(c) != std::string::npos;}, ' ');
11+
std::cout << mystr << std::endl;
12+
return 0;
13+
}
14+
15+
/*
16+
Hello How is he He s fine he s good
17+
*/

0 commit comments

Comments
 (0)