Ambil tiga input, serangkaian teks T,; serangkaian karakter untuk menggantikan F,; dan serangkaian karakter untuk menggantikannya dengan R,. Untuk setiap substring Tdengan karakter yang sama (tidak sensitif huruf) F, gantilah dengan karakter dalam R. Namun, simpan case yang sama dengan teks aslinya.
Jika ada lebih banyak karakter Rdari pada F, karakter tambahan harus sama dengan mereka R. Jika ada angka atau simbol di dalamnya F, maka karakter yang sesuai di dalamnya Rharus menyimpan case-nya R. Fbelum tentu muncul di T.
Anda dapat mengasumsikan semua teks akan berada dalam kisaran ASCII yang dapat dicetak.
Contohnya
"Text input", "text", "test" -> "Test input"
"tHiS Is a PiEcE oF tExT", "is", "abcde" -> "tHaBcde Abcde a PiEcE oF tExT"
"The birch canoe slid on the smooth planks", "o", " OH MY " -> "The birch can OH MY e slid OH MY n the sm OH MY OH MY th planks"
"The score was 10 to 5", "10", "tEn" -> "The score was tEn to 5"
"I wrote my code in Brain$#@!", "$#@!", "Friend" -> "I wrote my code in BrainFriend"
"This challenge was created by Andrew Piliser", "Andrew Piliser", "Martin Ender" -> "This challenge was created by Martin Ender"
// Has a match, but does not match case
"John does not know", "John Doe", "Jane Doe" -> "Jane does not know"
// No match
"Glue the sheet to the dark blue background", "Glue the sheet to the dark-blue background", "foo" -> "Glue the sheet to the dark blue background"
// Only take full matches
"aaa", "aa", "b" -> "ba"
// Apply matching once across the string as a whole, do not iterate on replaced text
"aaaa", "aa", "a" -> "aa"
"TeXT input", "text", "test" -> "TeST input"
"The birch canoe slid on the smooth planks", "o", " OH MY "sangat lucu, tetapi saya menyukai contoh itu.
"TeXT input", "text", "test"