RegEx Lowercase Letters and Hyphen

regex

Solution

This will catch 1 or more characters that are either lowercase a-z or the hyphen

[a-z\-]+

The trick is to escape the hyphen with a backslash.

For completeness, you can add an appropriate boundary such as \b on each end to signify a full word match, or ^ and $ to make it match a full line.

Problem

Can someone help me write a regex that matches only all lower case letters plus hyphens. Example: this-page-name

Original source