jquery - javascript Truncate string after comma -
i'm looking way remove comma , comes after in string, example:
important, not important
i'd remove ",not important"
any ideas? in advance!
str = str.substring(0, str.indexof(','));
but you'd have sure comma in there (test before).
another possibility use split()
:
str = str.split(',')[0];
this works without testing beforehand might perform unnecessary string operations (which negligible on small strings).
Comments
Post a Comment