Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Removing last characters from string

From: joel:neely:fedex at: 5-Jan-2003 15:06

Hi, Frantisek, The set-word isn't needed. Frantisek Fuka wrote:
> Is there a simpler way to remove last 2 characters from string > than this: ? > > str: head clear skip tail str -2 > >> foo: "abcdef"
== "abcdef"
>> clear skip tail foo -2
== ""
>> foo
== "abcd" The use of CLEAR modifies the series to which FOO refers, so you don't need to set the result back into FOO. If you want to do the removal and then immediately use the truncated value, then prepending the HEAD will yield that value without the need for another reference to (or setting of) FOO, as in
>> foo: "0123456"
== "0123456"
>> head clear skip tail foo -2
== "01234" HTH! -jn-