Substring Detection? Pythonically?

Fredrik Lundh effbot at telia.com
Thu Oct 5 11:24:51 EDT 2000


Joshua wrote:
> Was the original question hoping for matches only on the leftmost part of
> the string, or matches on any part of the string?
> 
> The original said that "th" matched against "that" and "they".  Would "hat"
> match against "that" or would it not match at all?

all posted solutions assumed a prefix match, so if Stephen
wanted something else, I'm sure he'd complained by now ;-)

(it may not be obvious, but "not string.find(str, prefix)" is only
true if str *starts* with prefix)

</F>




More information about the Python-list mailing list