replace

Replace occurrences of from with to in subject in a new array.

  1. E[] replace(E[] subject, R1 from, R2 to)
    E[]
    replace
    (
    E
    R1
    R2
    )
    (,
    R1 from
    ,
    R2 to
    )
    if (
    is(Unqual!E : Unqual!R1)
    )
  2. T[] replace(T[] subject, size_t from, size_t to, Range stuff)

Parameters

subject E[]

the array to scan

from R1

the item to replace

to R2

the item to replace all instances of from with

Return Value

Type: E[]

A new array without changing the contents of subject, or the original array if no match is found.

Examples

assert("Hello Wörld".replace("o Wö", "o Wo") == "Hello World");
assert("Hello Wörld".replace("l", "h") == "Hehho Wörhd");

See Also

Meta

Suggestion Box / Bug Report