<br><br>
<div class="gmail_quote">On Mon, Aug 2, 2010 at 2:22 PM, John Nagle <span dir="ltr"><<a href="mailto:nagle@animats.com">nagle@animats.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">On 8/2/2010 12:52 PM, Thomas Jollans wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">On 08/02/2010 09:41 PM, John Nagle wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">On 8/2/2010 11:02 AM, MRAB wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">John Nagle wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">The regular expression "split" behaves slightly differently than<br>string split:<br></blockquote>
</blockquote>occurrences of pattern", which is not too helpful.<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br></blockquote>It's the plain str.split() which is unusual in that:<br><br>1. it splits on sequences of whitespace instead of one per occurrence;<br>
</blockquote><br> That can be emulated with the obvious regular expression:<br><br> re.compile(r'\W+')<br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">2. it discards leading and trailing sequences of whitespace.<br></blockquote><br> But that can't, or at least I can't figure out how to do it.<br>
</blockquote><br>[ s in rexp.split(long_s) if s ]<br></blockquote><br> Of course I can discard the blank strings afterward, but<br>is there some way to do it in the "split" operation? If<br>not, then the default case for "split()" is too non-standard.<br>
<br> (Also, "if s" won't work; if s != '' might)<br><br> John Nagle<br><font color="#888888">-- <br></font></blockquote>
<div> </div>
<div> </div>
<div>What makes it non-standard? The fact that it's not a 1-line regex? The default case for str.split is designed to handle the most common case: you want to break a string into words, where a word is defined as a sequence of non-whitespace characters. </div>
<div> </div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><font color="#888888"><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>