Created
April 25, 2013 19:03
-
-
Save lxe/5462224 to your computer and use it in GitHub Desktop.
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
var r = new RegExp( | |
// ^ - not the following... | |
// \/\? - slash and a question mark | |
// + - 1 or more of them | |
'[^/?]+' | |
// Followed by (but don't capture this!)... | |
// ?= - don't capture! | |
// ^ - not the following... | |
// / - a slash | |
// * - 0 or more of those | |
// $ - followed by the end of line | |
+ '(?=[^/]+$)' | |
); | |
console.log('http://a.com/b/c/this_is_what_we_want?q=poop'.match(r).toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment