(In the case of TLE the fields themselves don't contain space but some fields run into each other, e.g. "Mean Motion" and "Revolution Number", and so do the two "Checksums" -- if wikipedia is to be believed.)
This additional 'split' functionality is a sort of multi-slice, and String.prototype.slice is generally useful. It is easy enough to implement, but then so is isNaN, isFinite, Date.now, and Array.isArray (a careful toString == "[object Array]"), etc, etc. Is it useful enough, worth rounding out the 'split' function's capabilities? ------------------------------- From: Rick Waldron I just spent some time researching TLE and it appears that no data value will ever have a space within the value itself - making a space the delimiter. Anyway, most languages include a string chunk function that returns an array. -Rick On Saturday, March 24, 2012 at 1:56 PM, Russell Leggett wrote: This seems special purpose enough (as you say, for legacy formats) and easy enough to implement, that it probably doesn't warrant being included in the language. - Russ On Mar 23, 2012, at 5:36 PM, "Roger Andrews" <[email protected]> wrote: String.prototype.split is good for cutting records into fields based on a delimiter string or regexp. E.g. rec.split( ',' ) // split CSV record (no commas in fields) rec.split( /\s+/ ) // split into whitespace-separated fields How about extending 'split', or inventing a new method 'splitlen', which splits a record into defined-length fields? This simplifies a long list of 'substring's. Old data formats invented in the days of punch-cards are still around. For example NASA's two-line element set (http://en.wikipedia.org/wiki/Two-line_element_set) which records the orbital elements of Earth satellites. E.g. here is the TLE for for International Space Station: ISS (ZARYA) 1 25544U 98067A 08264.51782528 -.00002182 00000-0 -11606-4 0 2927 2 25544 51.6416 247.4627 0006703 130.5360 325.0288 15.72125391563537 Proposed design: split( len1, len2, len3, len4, ..... ) // returns array of fields where each numeric length argument either (1) captures a field of the given length if positive, or (2) ignores a field of the absolute given length if negative. The special argument "*" could repeat the previous argument to the end of the record. Examples: // chop into 5-char fields rec.split( 5, "*" ) // capture a 1-char and a 5-char field and all chars after index 17 rec.split( -7, 1, 5, -4, Infinity ) _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

