const str = "hello,how,are,you,today?" const pieces = str.split(/[s,]+/) const last = pieces[pieces.length - 1] console.log({last}) Run code snippet