Product Site

5.1.7.81. overlay

Returns a copy of the receiving string, which, starting at the nth character, is overlaid with the string new, padded or truncated to length length. The overlay can extend beyond the end of the receiving string. If you specify length, it must be a positive whole number or zero. The default value for length is the length of new. If n is greater than the length of the receiving string, padding is added before the new string. The default pad character is a blank, and the default value for n is 1. If you specify n, it must be a positive whole number.
Example 5.117. String class — overlay method
"abcdef"~overlay(" ",3)         -->    "ab def"
"abcdef"~overlay(".",3,2)       -->    "ab. ef"
"abcd"~overlay("qq")            -->    "qqcd"
"abcd"~overlay("qq",4)          -->    "abcqq"
"abc"~overlay("123",5,6,"+")    -->    "abc+123+++"