I need to remove the last 2 characters of a string, only if the 2nd to last character is a space.
Examples:
Doe, John J
Doe, Jonathan K
Need these to return as
Doe, John
Doe, Jonathan
The last character could be any of the 26 letters in the alphabet and the amount of characters before this could be any number.
Essentially, I need to find the last space and if there is only 1 letter following it, remove that space and letter from the string. Any ideas would be appreciated.
I did figure out a different way as well. I used substring to return the last 2 characters of the string and then did a check if the substring starts with a space. This ended up giving me the result I needed. But I will definitely work with yours as well to see which one works best. I appreciate the response.