Created
June 5, 2015 13:27
-
-
Save refo/47632c8a547f2d9b6517 to your computer and use it in GitHub Desktop.
javascript - Remove leading slashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'/example/string/'.replace(/^\/+/g, ''); | |
// Should remove all leading slashes and return 'example/string/' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beautiful, absolutely brilliant! Needed something like this in a node project I'm maintaining, thank you heaps ❤️