Hi Tom,
TSubString::String returns the original string (and do not use
TSubString::Data which does
take into account the dropped trailing characters).
Use
TString z(y.Strip(TString::kTrailing,' '));
Cheers,
Philippe.
Tom Roberts wrote:
> ROOT 5.22/00 (trunk_at_26997, Mar 10 2009, 22:56:00 on macosx)
> CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008
> Type ? for help. Commands must be C++ statements.
> Enclose multiple statements between { }.
> root [0] TString y(" y ")
> root [1] y.Strip().String()
> (class TString)" y "
> root [2] y.Strip(TString::kTrailing,' ').String()
> (class TString)" y "
>
> I expected the trailing spaces to be removed.
>
> root [3] y.Strip(TString::kBoth,' ').String()
> (class TString)" y "
>
> I expected all spaces to be removed.
>
> Am I missing something?
>
> OK, I'm guessing that TSubString::String() just returns the TString of
> which the substring is a part. If so, please document that in the
> reference manual (I certainly expect String() to return a string
> representing the object, not some ancestor object).
>
>
> How do I use this to remove the initial and trailing spaces from the
> string (NOT a sub-string)? I sure expected this to work:
> root [0] TString y(" y ")
> root [1] TString z(y.Strip(TString::kTrailing,' ').Data())
> root [2] z
> (class TString)" y "
> root [3]
>
> And this:
> root [0] TString y(" y ")
> root [1] TString z(y.Strip(TString::kBoth,' ').Data())
> root [2] z
> (class TString)"y "
>
> So I think there is a bug here.... Looks like I just have to write the
> obvious but rather inefficient loops....
>
>
> Tom Roberts
>
Received on Mon Mar 16 2009 - 19:15:09 CET
This archive was generated by hypermail 2.2.0 : Tue Mar 17 2009 - 11:50:02 CET