How to match slugs?

Slugs are the parts of the url in between the /’s. It’s usually good for these to adhere to specific rules to prevent issues with URL encoding differences between different browsers and mobile devices.

Simple Slugs

If you stick with these, you should never have issues with slugs again as they are restricted to alphanumeric characters and -.

Regex: ^[a-z0-9-]+$



The latest tutorials sent straight to your inbox.