Is there an easy way in javascript to replace the last occurrence of an '_' (underscore) in a given string?
You don't need jQuery, just a regular expression.
This will remove the last underscore:
var str = 'a_b_c'; console.log( str.replace(/_([^_]*)$/, '$1') ) //a_bc
1.4m articles
1.4m replys
5 comments
57.0k users