Created
December 14, 2017 03:52
-
-
Save SergeyAxenov/807a5dc9b367c4084fc74d60157e2a52 to your computer and use it in GitHub Desktop.
Trims leading and trailing slash
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
#!/usr/bin/env bash | |
string='/this is my string' | |
[[ $string =~ ^/(.*) ]] && string=${BASH_REMATCH[1]} | |
[[ $string =~ (.*)/$ ]] && string=${BASH_REMATCH[1]} | |
echo $string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment