So say I pass this list:
test.Add("start_data1_end");
test.Add("more data1");
test.Add("start_this2");
test.Add("data3");
test.Add("tstart_hat4");
test.Add("data5");
test.Add("start_this3_end");
I specify start_ and _end as the parameters the end result should be:
start_data1_end
start_this3_end
If I choose to truncate then it's this:
data1
this3
I compiled, it works first shot. O_o
I'm really loving this late night shift, enabling me to go to bed late.
For those curious this is the function:
Code: Select all
xVector<string> Parser::FilterIn(xVector<string> data,string start,string end,bool truncate)
{
xVector<string> ret;
string tmp;
bool markasgood;
for(int i=0;data.Get(tmp,i);i++)
{
markasgood=false;
if((start.size()<=0 || tmp.find(start,0)==0) && (end.size()<=0 || tmp.find(end,tmp.size()-end.size())!=string::npos))
{
markasgood=true;
if(truncate)
{
tmp = DeleteOne(tmp,start,0,1);
tmp = DeleteOne(tmp,end,tmp.size()-end.size(),tmp.size());
}
}
if(markasgood)ret.Add(tmp);
}
return ret;
}