Thursday 15 May 2014

javascript - Remove all characters from a string from last comma onwards -



javascript - Remove all characters from a string from last comma onwards -

say have string looks this:

'welcome, bed made, tea ready.'

using jquery, how can remove characters after the lastly comma including lastly comma string shows as:

'welcome, bed made' // characters after lastly comma removed

simply read until lastly ,:

str = str.substr(0, str.lastindexof(","));

javascript jquery

No comments:

Post a Comment