Javascript Regex End Of String Python Replace Characters In String