#194 Please add string (Last-)Pos length parameter

Classes (154)

Strings and mutable buffers offer methods to find the first (last) occurrence of a needle in a haystack. At the moment the search starts at the beginning (end) or at a defined position and continue until a match was found or the end of string was reached.

Whilst working on the mutable buffer section class I found out that the pos does not need to search on areas that are hidden from the section. To achieve this the pos and lastpos methods would need a third optional argument that specifies the number of character to be searched.

string~pos(needle, start, length) -- same with lastpos

The same methods could be added to the mutable buffer (implementation is done in the StringClassMisc anyway).

Another remark: would it be possible to use a more efficient algorithm to search? At the moment each possible start of the needle is checked with a strcmp call. A faster approach would be to use an algorithm like KMP or Boyer–Moore.



  • Rick McGuire

    Rick McGuire - 2008-08-19

    Logged In: YES
    Originator: NO

    Committed revision 3014.

  • Mark Miesfeld

    Mark Miesfeld - 2010-09-16

    This request for a feature enhancement has been included in a prior release so the tracker item is being closed.



Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks