I have a RWCString which is ".../.../..../..../..." etc.
Is there a way to remove all the forward slashes with nothing ? I found methods first and last which return the index of the location, but then I need to loop through the RWCString.
I was hoping to do a pattern match and just remove all the flrward slashes in one go.
Any ideas please ?
Thanks,
Ami.
09-19-2009, 07:45 PM
jonnin
not sure what that string type is, but sprintf it into a char array and loop over *that* and poke it back into the string type when done. Many string classes prevent raw manipulation of their internal data, often because they maintain a "length" field that would become broken if you did this, so they simply don't allow it or make it extremely difficult. When you just can't find the workaround, the char array always works.
09-20-2009, 12:46 AM
vijayan
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).
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:
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.