Hi there,
Trying to create a script that replaces part of a given string with some character. For example:
$string = "Xtrm2Matt";
What I'd like to do is replace the 3rd, 4th and 5th characters with *, so it turns into Xt***Matt.
Ideally I'd like to create a function which returns the new string as I'll needing to use this around 3 times per script. The only snag is the string can be between 4 and 16 characters long (so perhaps an if statement to determine which characters to replace).
Any ideas on how to attempt this?
Cheers
Trying to create a script that replaces part of a given string with some character. For example:
$string = "Xtrm2Matt";
What I'd like to do is replace the 3rd, 4th and 5th characters with *, so it turns into Xt***Matt.
Ideally I'd like to create a function which returns the new string as I'll needing to use this around 3 times per script. The only snag is the string can be between 4 and 16 characters long (so perhaps an if statement to determine which characters to replace).
Any ideas on how to attempt this?
Cheers