Regex for Removing a Trailing Slash From a URL

Matches a single trailing slash at the very end of a string.

Published October 13, 2026

Matches a single trailing slash at the very end of a string.

Key points

  • Commonly used to normalize URLs so "/path" and "/path/" are treated the same

Example

\/$
More General articles