Well, i’m using regex to replace all white spaces to commas but there’s a white space at the end and i don’t know how to make the regex not replace him
What I have
25DEL 38DEL A73G
JS
var valor = $("#mapaArquivos option:selected").val().replace(/\s+/g, ", ");
Output
25DEL, 38DEL, A73G,
Right Output
25DEL, 38DEL, A73G
Thanks for the help anyway!
Trim the value before applying regex. this way there will be no trailing or leading spaces