<div><br class="Apple-interchange-newline">On Wed, May 23, 2012 at 7:50 AM, Boris Borcic <span dir="ltr"><<a href="mailto:bborcic@gmail.com" target="_blank">bborcic@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div id=":1o">Kind of beside the point, which is that the desire to repair the inconsistency between split and join has a better prospect at the split side of things than at the join side of things. The problems at the split side of things are comparatively minor.</div>
</blockquote><div><br></div><div> </div></div><div>The inconsistency that bugs me is the difference in split behavior between languages. Switching between languages means I have to constantly double check this. What is consistent is that you call string.split(separator) rather than separator.split(string) so changing that doesn't seem at all beneficial.</div>
<div><br></div><div>Python split has an optional <i>maxsplit</i> parameter:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>If maxsplit is given, at most maxsplit splits are done (thus, the list will have <b>at most maxsplit+1</b> elements).</div>
</blockquote><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">The remainder of the string after the last matched separator is included in the last part.</blockquote><br class="Apple-interchange-newline">
</div><div>Java split has an optional integer <i>limit</i> parameter:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>... the pattern will be applied at most limit - 1 times, the array's length will be <b>no greater than limit</b> ...</div>
</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>The remainder of the string after the last matched separator is included in the last part.</div></div></blockquote><div><br></div>
<div>C# split has an optional <i>count</i> parameter:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">The maximum number of substrings to return.<br>The remainder of the string after the last matched separator is included in the last part.
</blockquote><span style="font-family:arial,helvetica,sans-serif"><div><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div><span style="font-family:arial,helvetica,sans-serif">Ruby split has an optional limit parameter:</span></div>
</span><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="arial, helvetica, sans-serif">If limit is a positive number, <b>at most that number of fields</b> will be returned.</font></div><div>The remainder of the string after the last matched separator is included in the last part.</div>
</blockquote><font face="arial, helvetica, sans-serif"><div><font face="arial, helvetica, sans-serif"><br></font></div>Javascript has an optional limit parameter:</font><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><font face="arial, helvetica, sans-serif">It returns <b>at most limit</b> parts.</font></div></blockquote><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span style="font-family:arial,helvetica,sans-serif"><div>
<span style="font-family:arial">The remainder of the string after the last </span><span style="font-family:arial">matched</span><span style="font-family:arial"> </span><span style="font-family:arial">separator</span> <span style="font-family:arial,helvetica,sans-serif">is <b>discarded</b>.</span></div>
</span></div></blockquote><div><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div><font face="arial, helvetica, sans-serif">And I'm not mentioning the differences in how the separator parameter is interpreted. :-)</font></div>
<div><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div><span style="font-family:arial,helvetica,sans-serif">--- Bruce</span><br><div><font face="arial, helvetica, sans-serif">Follow me: <a href="http://www.twitter.com/Vroo" target="_blank">http://www.twitter.com/Vroo</a> <a href="http://www.vroospeak.com" target="_blank">http://www.vroospeak.com</a></font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div></div></div>