Last active
November 28, 2017 22:06
-
-
Save omniosi/74f9df211284755914a76db6f7cc2bba to your computer and use it in GitHub Desktop.
replace URL illegal characters with hyphen using RegEx
This file contains hidden or 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
" 0123456789 _+-.,!@#$%^&*();\/|<>"'~`?=:".replace(/[\/\s&!@#$%^*(){}[\];\\|<>"'?,.~`+=:]/g,'-') | |
// http://regexr.com/3h9d0 | |
/* To quote section 2.3 of RFC 3986: | |
"Characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde." | |
ALPHA DIGIT "-" / "." / "_" / "~" | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment