Hi,
Anyone know is it possible to insert a string value at a specific index in another string?
For example insert "234" into "657878768" at index 5 therefore overwriting it?
Cheers,
Mark.
my $original = '657878768';
my $replacement = '234';
# where in the string you want to insert it
my $index = 5;
# how many characters you want to replace
my $replace = length $replacement;
substr( $original, $index, $replace, $replacement );
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.