I have to check a string client side. If it contain only "\" (1, 2, or 1000 time) i need to refuse it. Code (with some of your suggestion that unfortunatly dont work):
value.replace(/\\/g, '');
if(value=="") alert("NO"); else alert("YES");
so :
value="\" = NO
value="\hello \people" = YES
value="\\\\hello \\people" = YES
value="hello \\people" = YES
value="hello people\" = YES
value="\\" = NO
value="\\\\\\" = NO
value="\\ \\\\ \ \\\" = NO
value.replace(/\\/g, '');. It needs to bevalue = value.replace(/\\/g, '');.replacedoesn't change the string it's called on, it returns an updated string. See the examples in the answers below./\\/gto/[\\\s]+/g, which will remove both forward slashes and whitespace.