Product Site

5.1.7.34. caselessChangeStr

Returns a copy of the receiver object in which newneedle replaces occurrences of needle. If count is not specified, all occurrences of needle are replaced. If count is specified, it must be a non-negative, whole number that gives the maximum number of occurrences to be replaced. The needle searches are performed using caseless comparisons.

Here are some examples:
Example 5.74. String class — caselessChangeStr method
Say "AbaAbb"~caselessChangeStr("A","")     -->    "bbb"
Say AbaBabAB~changeStr("ab","xy")          -->    "xyxyxyxy"
Say AbaBabAB~changeStr("ab","xy",1)        -->    "xyaBabAB"