<br><br><div class="gmail_quote">On Mon, Apr 6, 2009 at 6:09 AM, Aahz <span dir="ltr"><<a href="mailto:aahz@pythoncraft.com">aahz@pythoncraft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Mon, Apr 06, 2009, spir wrote:<br>
><br>
> Some time ago on this list was mentionned swapping sub-strings inside<br>
> a string....<br>
><br>
> * Sub-strings to be swapped must not be single characters.<br>
<br>
</div>This seems like an odd requirement. In any case, posting as a recipe<br>
seems the way to go.</blockquote><div><br>I think the meaning of this was sub-strings must not be limited to single characters.<br><br>There's a more general operation here that I've used on occasion:<br><br> multiReplace(text, {"old value": "new value", "old2" : "new2", ...})<br>
<br>which replaces all the old values with the new values. In a sense this is a generalized form of translate. Swap is a special case of this. In the case of overlapping strings, the earliest match wins. If two strings share a common prefix, then there needs to be a tiebreaking rule for that: shortest or longest wins.<br>
<br>--- Bruce<br></div></div>