#105 Add a method that will return string subwords as an array.

v4.2.0
closed
Classes (154)
none
5
2014-04-15
2007-02-03
No

It would be very handy if the string class supported a method that would return an array of word tokens. This would ideally be like the subword class, but return an array rather than a string. This would be particularly handy when combined with DO OVER

do word over string~wordlist
say word
end

Discussion

  • Rony G. Flatscher

    Logged In: YES
    user_id=662126
    Originator: NO

    What would be the characters delimiting words? Just blanks, or also other whitespace? What about punctuation characters?

    What constitutes a word? Just the letters, a combination of letters and digits?

    How about non-US-characters which are part of words?

    Ideally, this method should truly be able to deal with words of all kind correctly. (But I thought that would become possible only with Unicode and the test-functions going with it?)

     
  • Jon Wolfers

    Jon Wolfers - 2008-10-19

    Is this functionality not already available?

    ........................................... rexxtry.rex on WindowsNT
    s = 'The cat sat on the mat'
    ........................................... rexxtry.rex on WindowsNT
    do w over s~makearray(' ') ; say w ; end
    The
    cat
    sat
    on
    the
    mat
    ........................................... rexxtry.rex on WindowsNT

    thanks,

    Jon

     
  • Mark Miesfeld

    Mark Miesfeld - 2011-01-19

    I'm going to close this RFE because at some point it was implemented:

    str = 'Now is the time for all good men to come to the aid of their country.'

    do i over str~makeArray(" ")
    say i
    end

    works in .4.1.0.

     
  • Rick McGuire

    Rick McGuire - 2011-01-19

    And I'm going to reopen it because this has NOT been implemented. makearray(" ") is not semantically equivalent to what I've requested here. In particular, it does not apply the same semantics as subword with respect to multiple blanks between the word tokens.

     
  • Mark Miesfeld

    Mark Miesfeld - 2011-01-19

    Yeah, you're right. I thought of multiple spaces too late.

     
  • Rick McGuire

    Rick McGuire - 2011-02-03

    final Committed revision 6692. This has been added as the subWords method.

     
  • Mark Miesfeld

    Mark Miesfeld - 2012-08-07

    Mass updated this one by mistake. Put it back where it was.

     
  • Rick McGuire

    Rick McGuire - 2014-04-15
    • status: pending --> closed
    • Pending work items: --> none
     


Anonymous

Cancel  Add attachments