May not be more elegant but more general: WS=. TAB,' ' str=. 'Trailing whitespace... ',TAB,' ',TAB -.str e. WS 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 i:~-.str e. WS 21 str{.~1 i:~-.str e. WS Trailing whitespace.. str{.~>:1 i:~-.str e. WS NB. Off by one Trailing whitespace... 13 : 'y{.~>:1 i:~-.y e. x' NB. Generalized tacit version ] {.~ [: >: 1 i:~ [: -. e.~ WS (] {.~ [: >: 1 i:~ [: -. e.~) str Trailing whitespace...
On Tue, Dec 9, 2014 at 9:57 AM, Kenneth Lettow <klet...@thomasnet.com> wrote: > See http://www.jsoftware.com/docs/help803/user/lib_strings.htm . > > On Tue, Dec 9, 2014 at 9:53 AM, Jon Hough <jgho...@outlook.com> wrote: > > > Given a string, I am looking for a terse / elegant way to trim the > > trailing whitespace, similar toJava / C# .trim() method for strings.This > is > > my version: > > WS =: ' ' NB. whitespace > > > > removeTrailing =: ]`}.@.(' ' = {.)^:_&.|. > > > > > > Is there a better way? > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm