BSalunke
BSalunke

Reputation: 11727

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

Hi I have a string 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

Upvotes: 0

Views: 327

Answers (3)

Jan S
Jan S

Reputation: 1837

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

Upvotes: 2

Srinivas
Srinivas

Reputation: 1790

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?

Upvotes: 0

Alok Save
Alok Save

Reputation: 206528

You first find the string then you erase it.

Upvotes: 1

Related Questions