On Mon, 2011-03-21 at 13:07 -0400, Terry Carmen wrote: > I'm trying to match any URL that points to a URL shortener. > > They typically consist of http(s) followed by a domain name, a slash > and a small series of alphanumeric characters, *without a trailing "/" > or file extension*. > > I seem to be having pretty good luck matching the URL, however I can't > figure out how to make the regex explicity *not* match anything that > ends in a slash or contains an extension. > > For example, I want to match "http://asdf.ghi/j2kj4l23", but not > "http://asdf.ghi/j2kj4l23/abc.html" or "http://asdf.ghi/j2kj4l23/" > > I tried using the perl negative look-ahead as both : (?!/) and (?!\/) > without success. > > Can anybody toss me a clue? > Have you looked at the DecodeShortURLs plugin? That would seem to do what you need *and* check whether the shortened URL points to anything harmful.
Martin