0
I have this function in javascript and need to ignore the whitespace of the string. I think the function is removing the "Blank Spaces". Does anyone know how I use this same function without removing the blanks?
function getParameterByName(name) {
if (name !== "" && name !== null && name != undefined) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace("/\+/g", " "));
} else {
var arr = location.href.split("/");
return arr[arr.length - 1];
}
}
I didn’t understand anything, you say first "I need you to ignore the whitespace" and then "without removing the whitespace". You could explain better what you want by providing an example of input and output of the desired result?
– Guilherme Nascimento
Hello Guilherme, 13dev solved the function. I have the string "TABLE TENNIS" which had a null result. Now with the new function it brings with the blanks. Thanks!
– Denis Futida
Although solved, was very confused the question. Blank Spaces and blanks are the same thing. rs
– Sam
I found nothing confusing, the function has to ignore the presence of white spaces, that is, turn your back on them :)
– user60252