How to find the offset of the last instance of a repeating character in a string? (Geoff Canyon)

Geoff Canyon gcanyon at
Sun Nov 4 21:49:51 EST 2018

On Sun, Nov 4, 2018 at 4:34 PM Mark Wieder via use-livecode <
use-livecode at> wrote:

> On 11/4/18 10:40 AM, Geoff Canyon via use-livecode wrote:
> > I also added a "with overlaps" option.
> My problem with the pWithOverlaps parameter is that is requires a priori
> knowledge of the data being consumed. If you already know there are
> overlaps then you'd set the parameter to true. If you don't know whether
> or not there are overlaps, then you'd need to set it to true so you
> don't miss anything (aside, of course, for the trivial case where you
> don't care whether or not there are overlaps - is there a use case for
> this?).
> The only time you would set it to false is after you've already
> determined that there are no overlaps, and the time spent on that would
> probably more than offset the extra processing in the function.

I'm not sure I agree that it would be so unlikely to know that overlaps
won't occur (or that it's unreasonable to not want them). If I'm looking
for every instance of "romeo" in romeo and juliet, then obviously I'm not
expecting, nor do I want, overlaps. Likewise, overlaps can only occur if
the search string allows for them, so "romeo" makes it impossible from the
get go

That said, it seems reasonable to default overlaps to true rather than
false. I'll set it up that way when I add the modification below.

On Sun, Nov 4, 2018 at 4:02 PM Brian Milby via use-livecode <
use-livecode at> wrote:

> put kList is not empty into pWithOverlaps

Good point -- I suppose it also makes sense (albeit that the speed
improvement would be trivial) to not bother even building kList if the term
to be found is a single character.


More information about the use-livecode mailing list