3 ms·
Why bother matching balanced parens? just match everything until nonencoded space. These are valid urls, no? example.com/( example.com/dkjflkj)sdkfj(/.
by njharman 16y ago
Why bother matching balanced parens? just match everything until nonencoded space.
These are valid urls, no?
example.com/(
example.com/dkjflkj)sdkfj(/.
example.com/.
example.com//////:
example.com/anycharacters_in_any_order_as_long_as_certain_ones_are_encoded
There's no way to tell if trailing punctuation is part of valid url or not. You can assume trailing punc is not and chop it off. Which should be correct 99.999 of the time. Similar with surrounding braces,brackets,parens. If you see one at start assume the one at end is not part of url.
- drivebyacct2 16y agoIronically that solution doesn't work for lots of wikipedia links that end in a paren.
- _delirium 16y agoThere's actually a lot of Wikipedia articles that end with punctuation, which I get bitten by at HN relatively frequently. For example, there are a bunch of Supreme Court cases involving companies that end with an "L.L.C.", "Inc." or "Co.", like: http://en.wikipedia.org/wiki/Riegel_v._Medtronic,_Inc http://en.wikipedia.org/wiki/Riegel_v._Medtronic,_Inc.