I need to replace all the letters in a sentence to * (asterisks).
My code is
var password='hello world';
password.replace(/\S/g, '*');
All the letters are getting replaced but not the space. How can that too be replaced ?
I need to replace all the letters in a sentence to * (asterisks).
My code is
var password='hello world';
password.replace(/\S/g, '*');
All the letters are getting replaced but not the space. How can that too be replaced ?
Change your code to:
var password='hello world';
password=password.replace(/[\S ]/g, '*');
Tested and illustrated here: http://jsfiddle.net/HSP2P/