string filtering on c++
given a string literal in c++ i have to remove t开发者_高级运维oxic words like stupid etc by ###.
Suppose i have my toxic words in an array like
char[][]={"...",".."...and more...}
and my string is like
char str[]="......."
any particular library func that could help me here.
thanks in advance for help
boost string algorithms
Example:
string str1="Hello Dolly, Hello World!"
replace_first(str1, "Dolly", "Jane"); // str1 == "Hello Jane, Hello World!"
replace_last(str1, "Hello", "Goodbye"); // str1 == "Hello Jane, Goodbye World!"
erase_all(str1, " "); // str1 == "HelloJane,GoodbyeWorld!"
erase_head(str1, 6); // str1 == "Jane,GoodbyeWorld!"
Download boost from here
Documentation of this particular library is here (page 5 is about replace algorithms)
精彩评论