Repetition in string search methods

For the Compleat Fan
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Repetition in string search methods

Post by newdep »

Hello All,

Im wondering is a "String seach" could be more easier then creating a loop
where the search take place in.

The commands 'match and 'find do a great job, though they have
disadvantages:

'find:
Searches but is not able to find from an index pointer returned by newlisp,
except when builing your own index or by manilupating the buffer where you
are searching in..

'match:
Matches and return the result, but only once. Thus to have a repeated
match in a xxx-buffer a loop must be created. An index pointer.

For both 'find and 'match it would be great to have an internal index-pointer
returned for every 'find or 'match found, that is for 'find at least being able
to do something like a 'next e.i.:

;; in the case below the 'next is an function
;; which could slow down searches when build as newlisp and not a C
;;
>(while (next (find "str" buff )))
(1 40 500 677 5774 )

;; for 'match
;; the next return would be nice..
> (match "*1*" "1 2 3 4 5 1 2 3 4 5 1 2 3 4 5")
( "1" "2 3 4 5" "1" 2 3 4 5" "1" "2 3 4 5")

I can emagine why the "RegExp" Perl lib was included because its
quick and handy, 1 big disadvantage i find in RegExp is that its
too cryptic though.. (already after 1 week later relooking in the code ;-)

Im pritty sure im overlooking some good newlisp function for this ;-)
So if you have a hint on a buildin newlisp function to overcome the
loop issue on 'find ill be very happy. For 'match perhpas its a nice feature
"Lutz" might think about? Or perhpas a 'next function?

Regards,

Norman.

Locked