<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 28, 2015 at 8:43 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(3) Using a regular expression is probably the "right" answer, at least<br>
from a comp sci theorectical perspective. This is precisely the sort of<br>
thing that regexes are designed for. Unfortunately, regex syntax is<br>
itself a programming language[1], and a particularly cryptic and<br>
unforgiving one, so even quite experienced coders can have trouble.<br></blockquote><div><br></div><div>indeed -- we all know the old maxim:</div><div><br></div><div>"I had a problem, and thought "I know, I'll use regular expressions" -- now I have two problems.</div><div><br></div><div>And the Python "obvious way to do it" has always been for simple string manipulation, see if what you need is in a string method before you bring out the big guns of REs</div><div><br></div><div>After all, if "use REs" was the answer to simple string manipulation problems, the string object would have a lot fewer methods.</div><div><br></div><div>So: I've frequently had this use-case, too -- it would be a nice enhancement that would had substantial utility to strings. Whether it used an re under the hood or not should be an implementation detail.</div><div><br></div><div>-CHB</div><div><br></div></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>