I've been grappling with a problem involving removing a specific character at a known position from the back of a string. Here's the situation:
Currently, I have strings like:
'RX8567' 'A8532' '18256'
I want to delete the first '8' I encounter in each string. However, I would prefer to tackle this issue from the end of the string, as I am uncertain of the number of alphanumeric characters at the beginning. From the back, I know that the character I want to remove will always be the 4th character. So, if the '8' is the fourth character of the string from the end, I want to remove it. I've managed to achieve this from the front with the following code:
var string = 'A8532'
var string = string.slice(0,1) + string.slice(2);
This should result in:
'A532'
However, this only works if the '8' immediately follows the 'A'. Is there an alternate or simpler method of achieving this while working from the back of the string as described? Thank you in advance!