Which regex would be good to use in order to match this type of string.
my-name-is-david
What have you tried?
/\W/
tried this but did not work
That pattern would match a single non-word character.
Many regexes can match that string. All depends on how specific you need it to be. Here’s one option: /(?:[a-z]±)+[a-z]+/
That will match any lowercase phrase made up of words separated by hyphens.