Hi All, Heres an updated version of 'replace from Bo, that fixes an issue with 'replace and tags. (where the correct length of the tag was not taken into account during a replace), that I sent in as a feedback issue. I have been testing it and seems to be working properly. If you find any problems please let [EMAIL PROTECTED] know. If there is no problem then this updated version should (hopefully) end up in the next core release. This updated 'replace also has a case refinement An example of the problem that was identified in the current rebol/core 'replace >> replace "This is a string with a <tag> in it" <tag> <tag2> == "This is a string with a <tag2>g> in it" or >> replace "This is a string with a <tag> in it" <tag> "" == "This is a string with a g> in it" Cheers, Allen K
REBOL [ Title: "Case-sensitive REPLACE function" Date: 14-Mar-2000 Author: "Bohdan Lechnowsky" Email: [EMAIL PROTECTED] File: %replace.r Purpose: { Adds the ability to do a case-sensitive REPLACE in a string or a block. Also fixes IRNumber 941. } ] replace: func [ {Replaces the search value with the replace value within the target series.} 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 save-target len ][ save-target: target if (any-string? target) and ((not any-string? :search) or (tag? :search)) [search: form :search] len: either any [any-string? target any-block? :search] [length? :search] [1] while [target: either case [find/case target :search][find target :search]] [ target: change/part target :replace len if not all [break] ] save-target ]