As far as I know, I don't think there is anything that strips it and returns the material that was stripped. Regex's would be your best bet.<br><br>Daniel<br><br><div class="gmail_quote">On Tue, Mar 23, 2010 at 6:09 PM,  <span dir="ltr"><<a href="mailto:python@bdurham.com">python@bdurham.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div style="font-family: Arial; font-size: medium;" dir="ltr"><div>I'm looking for a pythonic way to trim and keep leading whitespace in a string.</div>
<div> </div>
<div>Use case: I have a bunch of text strings with various amounts of leading and trailing whitespace (spaces and tabs). I want to grab the leading and trailing whitespace, save it, surround the remaining text with html tags, and then add back the leading and trailing whitespace.</div>

<div> </div>
<div>The only solution I can think of is regex, and that makes me think of the 2 proverbial problems that come with that :)</div>
<div> </div>
<div>Is there a 'better' solution than regex for this scenario? (Seems like this would be a common type of string processing).</div>
<div> </div>
<div>Thanks,</div>
<div>Malcolm</div>
<div> </div>
<div> </div></div></div><br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>~<br>
<div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup {  position:absolute;  z-index:9999;  padding: 0px 0px;  margin-left: 0px;  margin-top: 0px;  width: 240px;  overflow: hidden;  word-wrap: break-word;  color: black;  font-size: 10px;  text-align: left;  line-height: 13px;}</style>