Generation

generate functionSun, 13 Nov 2022

List all separate words in a given text, excluding special characters

const text = 'Hello, I am a string. I have different words.' const pattern = /[^\w]/g const textWords = text.split(pattern).filter(Boolean) console.log(textWords) // ["Hello", "I", "am", "a", "string", "I", "have", "different", "words"]

TypeScript
Generate More

Questions about programming?Chat with your personal AI assistant