replace method with a regex.
For instance, we can write:
const str = 'a_b_c'; console.log(str.replace(/_([^_]*)$/, '$1'))
to remove the underscore before the
To do that, we call
replace with a regex that searches for the last instance of an underscore with a character after it.
Then in the 2nd argument, we pass in
'$1' to remove the underscore from the last instance of the regex match.