Last active
April 14, 2017 03:08
-
-
Save mr21/890248860c39016cb80dd72c420daed6 to your computer and use it in GitHub Desktop.
JavaScript: some regexp
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
/[^/]*$/.exec( "https://asd.x/file.wav" )[ 0 ]; // "file.wav" | |
/[^/]*$/.exec( "file.wav" )[ 0 ]; // "file.wav" | |
/[^/]*$/.exec( "qwe.rty/" )[ 0 ]; // "" | |
/(?:([^/]*)\.([a-zA-Z\d]*))?$/.exec( "" ); // [ "", undefined, undefined ] | |
/(?:([^/]*)\.([a-zA-Z\d]*))?$/.exec( ".wav" ); // [ ".wav", "", "wav" ] | |
/(?:([^/]*)\.([a-zA-Z\d]*))?$/.exec( "://a.b/q/a.b.mp3" ); // [ "a.b.mp3", "a.b", "mp3" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment