Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove end spaces.
#1
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
#2
Macro Macro1441
Code:
Copy      Help
;single line

str s1="abcd  "
s1.rtrim
out s1

;multiline

str s2="ab  []cd  "
out s2.replacerx(" +$" "" 8)
out s2
#3
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:
Code:
Copy      Help
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.


Forum Jump:


Users browsing this thread: 1 Guest(s)