Case-insensitive replacement
Input
replace_ignore_case("FooBarfoo", "foo", "x")
Output
xBarx
Both 'Foo' and 'foo' are replaced with 'x'.
Full lesson preview
Replace all occurrences of a substring regardless of case, preserving non-matching text.
Problem statement
Task
Examples
Input
replace_ignore_case("FooBarfoo", "foo", "x")
Output
xBarx
Both 'Foo' and 'foo' are replaced with 'x'.
Input format
Output format
Constraints
Samples
Input
replace_ignore_case("Spam spam SPAM", "spam", "eggs")
Output
eggs eggs eggs
All three case variants of 'spam' are replaced by 'eggs'.