Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Multi-searches

From: joel:neely:fedex at: 20-Feb-2002 6:46

Hi, Philippe, Philippe Oehler wrote:
> I want to make multi-researches on a block of strings. > > The result I want is an array of index of all appereances of a name, > but the 'find word find only the first appereance >
Do you mean something like this?
>> blort: [1 2 0 3 0 4 5 6 0 7]
== [1 2 0 3 0 4 5 6 0 7]
>> find-all: func [b [block!] v [any-type!] /local result] [
[ result: copy [] [ forall b [if v = b/1 [append result index? b]] [ result [ ]
>> find-all blort 0
== [3 5 9] I used a block of numbers to save typing, but the principle is the same IMHO. HTH! -jn- -- ; sub REBOL {}; sub head ($) {@_[0]} REBOL [] # despam: func [e] [replace replace/all e ":" "." "#" "@"] ; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"} print head reverse despam "moc:xedef#yleen:leoj" ;