Should be simple,
Start from the end and keep going back one checking if the previous one was a '*', when this fails note the integer position and substring it.
simple
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iterator>
using namespace std;
void trim(string str)
{
string::size_type pos = str.find_last_not_of('*');
if(pos != string::npos) {
str.erase(pos + 1);
pos = str.find_first_not_of('*');
if(pos != string::npos) str.erase(0, pos);
}
else str.erase(str.begin(), str.end());
cout << str;
}
int main()
{
trim("*********************jfdkslfjdsfj**lds************");
cin.get();
}
output:
jfdkslfjdsfj**lds
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439