I have a variable that\'s a string and I want to replace the string with \"null\" if the variable contains only a space or multiple spaces. How can I do it?
How about this?
if(yourstring.replace(" ","").length()==0) { yourstring = null; }
Doesn't need regexes so should be a little more efficient than solutions that do.