How to check if a string only contains certain characters in js?

  discord, discord.js, javascript, node.js

I’m making a discord bot that allows you to play hangman. I need to check if a string only contains lowercase english letters and hyphens ("-").

I know how to check if it contains or doesn’t contain certain characters, but how do I check if it only contains specific characters?

Source: Ask Javascript Questions

LEAVE A COMMENT