Posts: 1,000
Threads: 253
Joined: Feb 2008
Gintaras,
I must have a hundred different ways removing unwanted spaces at the end of a string so I just wanted to see what kind of slick tricks you may have up your sleeve.
Thanks,
Jimmy Vig
Posts: 12,141
Threads: 143
Joined: Dec 2002
Macro
Macro1441
;single line
str s1="abcd "
s1.rtrim
out s1
;multiline
str s2="ab []cd "
out s2.replacerx(" +$" "" 8)
out s2
Posts: 1,000
Threads: 253
Joined: Feb 2008
rtrim! I missed that every time through the member functions.Good thing I asked. I've been doing it really long ways. Really hated having to put that stuff in my code because it makes it longer and ugly.
Here's one way I've been doing it:
str s="Hello "
for _i 0 s.len
,_s.get(s s.len-1 1)
,if _s=" "
,,s.remove(s.len-1 1)
out s
Too long for just removing spaces. A lot of the way's I've done it don't seem like they would be reliable.