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

[REBOL] Re: Newbie Q: Search and delete from a Block

From: rotenca:telvia:it at: 10-Oct-2002 1:24

Hi Gabriele,
> RPT> if all [any-string? target any [not any-string? :search tag?
> RPT> [search: form :search] > > Does this work? You have 'ALL as a local word...
Does not work. I forgot system/words/, i try also to remove the if (but i'm not sure that the efinal evaluation of the search value does not make fail the block of all in some cases) system/words/all [any-string? target any [not any-string? :search tag? :search] search: form :search]
> BTW, for a long string copying to a new string will probably be > faster than changing the original (unless you're not moving data > around at all, i.e. when SEARCH has the same length as > REPLACE...).
I fear that memory can become a problem with very long series! and additional test on the lenghts could slow the function, i think. ----- new version ---- replace: func [ {Replaces the search value with the replace value within the target series. Changed by ana} target [series!] "Series that is being modified." search "Value to be replaced." replace "Value to replace with." /all "Replace all occurrences." /case "Case-sensitive replacement." /local start end rule ][ rule: [to search start: search end: opt (end: change/part start replace end) :end] system/words/all [any-string? target any [not any-string? :search tag? :search] search: form :search] if all [rule: reduce ['some rule]] either case [parse/all/case target rule][parse/all target rule] target ] --- Ciao Romano