if the string contains only single byte characters, there are two options:
if portability of your code to non-roguewave implementations is not an issue, just do a regular expression pattern match and replacement. (note: this is easy, but not very efficient).
Code:
RWCString rwcstr( "abc/defgh/ijkl/mnopqr/st/uvwxyz" ) ;
rwcstr.replace( RWCRExpr( "/" ), "", all ) ;
if portability is desirable, use std::stable_partition to move all the '/' characters to the end of the string and then truncate the string. for example:
Code:
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
int main()
{
using namespace std ;
string str = "abc/defgh/ijkl/mnopqr/st/uvwxyz" ;
cout << str << '\n' ;
str.erase( stable_partition( str.begin(), str.end(), bind2nd( not_equal_to<char>(), '/' ) ),
str.end() ) ;
cout << str << '\n' ;
}
If your roguewave library build is based on the standard C++ library (this is the default), RWCString is just a wrapper over std::string. In this case, you can directly manipulate the underlying std::string object on which the RWCString is based.
Code:
RWCString rwcstr( "abc/defgh/ijkl/mnopqr/st/uvwxyz" ) ;
std::string& str = rwcstr.std() ;
str.erase( stable_partition( str.begin(), str.end(), bind2nd( not_equal_to<char>(), '/' ) ),
str.end() ) ;
Bookmarks