How can I remove certain characters from a string?

  • 0
    How to remove the following characters from a string: "." "-" "/" "\" "" (period, dash, slash, backslash and space)
    JavaScript Collin Shah, Feb 15, 2019

  • 3 Answers
  • 0
    string.replace (/ (\. | - | \ / | \\ |) / g, "");

    string - string variable
    Anonymous

  • 0
    you can try

    let str = "Hello. World-. About/Me \Help ";
    str.replace(/[\.\-/\\\s]/g, '')
    Anonymous

  • 0

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!