A fairly simple challenge: You will receive two inputs, a string and a number (the number may be taken as a string, ie
"123" instead of
If the string does not end in a number (ie, it does not match the regex
\d$), just append the number to the end of the string.
If the string does end in a number (ie, it matches the regex
\d+$), you should first delete that and then append the number.
Neither of the inputs will ever be invalid or empty (invalid is defined by the numerical input not containing only digits)
The number will never contain a
- or a
The string will never contain a newline, or unprintable non-whitespace characters.
abc123 + 345 -> abc345 123 + 1 -> 1 hello + 33 -> hello33 123abc123 + 0 -> 123abc0 ab3d5 + 55 -> ab3d55 onetwo3 + 3 -> onetwo3 99ninenine + 9999 -> 99ninenine9999