How to remove punctuation from a string in JavaScript?

To remove punctuation from a string in JavaScript, do this: string.replace(/[\p{P}\p{S}]/gu, '')

Here's how you do it:

const string = 'Hello World!,.;:#%$^&?+-*=';

const noPunctuation = string.replace(/[\p{P}\p{S}]/gu, '');

console.log(noPunctuation); // Hello World