   Trim
  for a C++ string variable anyone know how to remove white spaces to the left and right of an equal to sign, until we reach the next string.Ex.before...string s1 = "Variable    =    25";  after...string s1 = "Variable=25"; [edited by - kelaklub on August 1, 2003 10:56:02 AM]
  You can go through the string one character at a time and if the current character is equal to '' '' just remove it. you stated that you only want it done to the left or the right of the string, so you''ll have to employ some method for skipping the check/delete in the middle.   When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...;  I'm not brilliant with the STL at the moment, but maybe one of these (RemoveSpaces1() being preferable): #include <iostream>#include <string>#include <algorithm> inline void RemoveSpaces1( std::string& str ){    str.erase( std::remove( str.begin(), str.end(), ' ' ), str.end() );} void RemoveSpaces2( std::string& str ); void RemoveSpaces2( std::string& str ){    str.assign( str.begin(), std::remove( str.begin(), str.end(), ' ' ) );} int main(){    std::string str = "variable    =  5";    std::cout << str << std::endl;    RemoveSpaces1(str);//  RemoveSpaces2(str);    std::cout << str << std::endl;return 0;}There are also other ways, for example using a string stream.   [ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ] [edited by - Lektrix on August 1, 2003 12:04:12 PM];  these work too wellif I have...string st1 = "Angle   =  Angle P";   I want...string st1 = "Angle=Angle P";   [edited by - kelaklub on August 1, 2003 12:30:07 PM];  Well.. Just check each character from left to right until you find a '='-character. Then store this location to x. Loop backwards from x until you find something else than ' ', store that position to y. Then loop forwards from x until you find something else than ' ', store that position to z. Then concatenate the resultsstring result = s1.substr(0, y) + '=' + s1.substr(z, s1.length());simpel   ps. I like python>>>'='.join([x.strip() for x in "Angle   =  Angle P".split('=', 1)])'Angle=Angle P'  [edited by - civguy on August 1, 2003 1:44:45 PM];  Thank you all for shoving me in the right direction 