开发者

How to remove unwanted content from string in c++?

Hi I have a st开发者_C百科ring variable with large content. I have to remove unwanted line from the string content and keep remaining content as it is. Following is output that we get after printing the string:

string varString;
cout<<"String content :"<<endl<<varString<<endl;

Output is :
String content :
/abc/def/ghi/klm/run.so
call::myFuncton(int const&)
call::MY::Method(char const&)
.
.
.
call::MY::newFunction(char *&)

Now i have to remove "call::myFuncton(int const&)" line from above string variable and keep other data as it is. can any one tell tell me how i can remove that line from sting variable? Thanks in advance


You can use the function varString.find() to find the position where the string occurs, and then use varString.erase() to erase the text.


You first find the string then you erase it.


You can use Regex to replace the required string call::myFuncton(int const&) using Regex. You can find more information about using Regex in C++ from this link C++: what regex library should I use?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜