I’m using regEx and replace method to replace an empty space with a dash but I only want this to happen if there is a following character. For example
if the input field looked like this then replace empty space between temp and string with dash
input = "temp string";
if it looked like this then it would just remove the empty space
input = "temp ";
here is my regEx replace right now. But not sure how to check if there are trailing characters.
input.value.replace(/\s+/g, '-');
DEMO
\b(word boundaries) infojQuery.trim()api