Name: Anonymous 2009-11-25 21:52
Using c++, I have a string vector containing thousands of elements. I know I can erase a specific element using:
vectorName.erase(remove(vectorName.begin(),vectorName.end(),"whatever"),vectorName.end());
In that example it would get rid of any vector elements that equaled "whatever".
I'm looking to erase certain elements if anywhere in that element it has a certain combination of letters. In my case, I want to erase any URLs that make it into the vector, so I would erase any element that contained "http" or "www" in it.
I tried googling this, but I have no clue what to look for. Can anyone offer their expertise? Is there a one line solution using vectorName.erase()?
vectorName.erase(remove(vectorName.begin(),vectorName.end(),"whatever"),vectorName.end());
In that example it would get rid of any vector elements that equaled "whatever".
I'm looking to erase certain elements if anywhere in that element it has a certain combination of letters. In my case, I want to erase any URLs that make it into the vector, so I would erase any element that contained "http" or "www" in it.
I tried googling this, but I have no clue what to look for. Can anyone offer their expertise? Is there a one line solution using vectorName.erase()?