Fsharp: Replace String

By Xah Lee. Date: . Last updated: .

Replace string

// replace string

let xx = "in water."
let xresult = xx.Replace("water", "fire")
printfn "%s" xresult
// in fire.

Replace text by regex. ignore case

// replace text by regex. ignore case

open System.Text.RegularExpressions
let xtext = "Cats, lots cats."
let xout = Regex.Replace(xtext, "cat", "dog", RegexOptions.IgnoreCase)
printfn "%s" xout
// dogs, lots dogs.

Fsharp, String