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

v4.0
closed
Classes (154)
5
2012-08-14
2007-06-19
No

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.

Thanks!

Discussion

  • Rick McGuire

    Rick McGuire - 2008-08-19

    Logged In: YES
    user_id=1125291
    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.

     


Anonymous

Cancel  Add attachments





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

Sign up for the SourceForge newsletter:





No, thanks