text and pattern. While pattern occurs in text as a substring (a contiguous piece), find its **leftmost** occurrence and cut it out, joining the parts on either side.
Return what remains once there are no occurrences left.text="kcatcatt", pattern="cat" → 'kt'
Removing "cat" at index 1 gives "kcatt"; removing "cat" again leaves "kt".
text="ooxxoo", pattern="ox" → 'oo'
"ooxxoo" → "oxoo" → "oo".
text="abc", pattern="abcd" → 'abc'
The pattern is longer than the text, so nothing is removed.
text="kcatcatt", pattern="cat"
'kt'
Run checks the first 3 tests in your browser. Submit checks all 132 tests on the server, hidden ones included.