So I am parsing a string and I am tokenizing it using | as a delimiter. However, I want to make sure that I do not parse spaces ( in any amount ) and simply ignore them. However for some reason, nothing is working completely. Some spaces escape the check and get printed. here is my code:
white = value;
white.replace(/(^\s+|\s+$)/g, '');
if(white != null && white != '' && white != ' '){
console.log("IT IS NOT EMPTY");
}else{
console.log("IT IS EMPTY");
}
I cannot understand it.
These work:
" | "
" | | | "
BUT
" | | | | "
does NOT work...
Any suggestions?