Copy path to clipboardExamples
replace "-" "_" "foo-bar" โก "foo_bar"
replace "๐ฃ" "๐ฅ" "๐ฃ๐ฃ๐ฃ" โก "๐ฅ๐ฅ๐ฅ"
replace "๐จ" "๐ฉ" "๐จโ๐ฉโ๐งโ๐ฆ" โก "๐ฉโ๐ฉโ๐งโ๐ฆ"
Source
{-
Replace a section of `Text` with another inside a `Text` literal.
-}
let replace
: โ(needle : Text) โ โ(replacement : Text) โ โ(haystack : Text) โ Text
= Text/replace
let example0 = assert : replace "-" "_" "foo-bar" โก "foo_bar"
let example1 = assert : replace "๐ฃ" "๐ฅ" "๐ฃ๐ฃ๐ฃ" โก "๐ฅ๐ฅ๐ฅ"
let example2 = assert : replace "๐จ" "๐ฉ" "๐จโ๐ฉโ๐งโ๐ฆ" โก "๐ฉโ๐ฉโ๐งโ๐ฆ"
in replace