I have the following string which I ultimately need to have in the format of mm/yy
var expDate = 2016-03; var formatExp = expDate.replace(/-/g , \"/\
With a RegExp :
'2016-03'.replace(/^\d{2}(\d{2})-(\d{2})$/, '$1/$2')