I have a string like that:

var str = 'aaaaaa, bbbbbb, ccccc, ddddddd, eeeeee ';

My goal is to delete the last space in the string. I would use,

str.split(0,1);

But if there is no space after the last character in the string, this will delete the last character of the string instead.

I would like to use

str.replace("regex",'');

I am beginner in RegEx, any help is appreciated.

Thank you very much.

Edit
Report