REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: replace

replace  target  search  replace  /all  /case  /tail

Replaces a search value with the replace value within the target series.

Arguments:

target [series!] - Series that is being modified

search - Value to be replaced (converted if necessary)

replace - Value to replace with (called each time if a function)

Refinements:

/all - Replace all occurrences

/case - Case-sensitive replacement

/tail - Return target after the last replacement position

See also:

insert   remove   change  

Description

Searches target block or series for specified data and replaces it with data from the replacement block or series. Block elements may be of any datatype.

The /ALL refinement replaces all occurrences of the searched data in the target block or series.

str: "a time a spec a target"
replace str "a " "on "
print str
on ime a spec a target
replace/all str "a " "on "
print str
on ime on pec on arget
fruit: ["apples" "lemons" "bananas"]
replace fruit "lemons" "oranges"
print fruit
apples oranges bananas
numbers: [1 2 3 4 5 6 7 8 9]
replace numbers [4 5 6] ["four" "five" "six"]
print numbers
1 2 3 four five six 7 8 9


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin