I am attempting to remove all trailing white-space and periods from a string so that if I took either of the following examples:
var string = " .. bob is a string .";
or
var string = " . bob is a string . ..";
They would end up as:
"bob is a string"
I know diddly squat about regex
but I found a function to remove trailing white-space here:
str.replace(/^\s+|\s+$/g, "");
I tried modifying to include periods however it still only removes trailing white-space characters:
str.replace(/^[\s+\.]|[\s+\.]$/g, "");
Can anyone tell me how this is done and perhaps explain the regular expression used to me?