Friday, May 23, 2014

Re: matching the last part of a url

On 2014-05-23 16:10, Eric Smith wrote:
> http|www.foo.bar/baz/baz -> I want to match baz
> http|www.foo.bar/baz/baz/ -> I want to match baz/
> http|www.foo.bar/baz/baz/biz -> I want to match biz

Your "http|" is a little odd (I'd normally expect "https\=://", but if
that's actually what you have, you should be able to do something like

\(http|\S*\/\)\@<=\w\+\/\=\S\@!

It's a little sloppy, as it assumes that the results you want to find
match "\w\+" while other characters could legitimately be there.
But that should give you the foundation for improving it.

It roughly translates to

\(
http|\S*\/
\)\@>= assert that the stuff preceding this is contextually a URL
\w\+ the pattern we actually want
\/\= optionally a trailing slash
\S\@! assert that a non-whitespace doesn't follow the slash

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: