1. <script>
    2. //备选字符集
    3. /*
    4. [0-9] \d
    5. [a-z]
    6. [A-Z]
    7. [A-z]
    8. */
    9. var str = "32313dhhhdgaggff";
    10. var reg = /\d/g;
    11. console.log(str.replace(reg,"*"))
    12. </script>
    1. <script>
    2. /*
    3. w [ 0-9a-zA-Z_]
    4. .表示所有的字符
    5. \s表示空格的意思
    6. */
    7. var a= "hellow_worder1245WS"
    8. console.log(a.replace(/\w/g,"*"))
    9. console.log(a.replace(/./g,"*"))
    10. </script>
    1. <script>
    2. var a = "hellow.word"
    3. var reg = /\./;
    4. console.log(a.replace(reg,"*"));
    5. </script>