Tuesday, August 31, 2010

Re: Vim RE and lazy operator

> The problem is that you can have more then one quote before @. If there is more
> then one quote then you will capture everything starting from the first quote,

ZyX is right, testing Tom's expression "\zs.\{-}@.\{-}\ze" with the
code <a class="some class" href="mailto:email@example.com" title="some
title">link</a>
has been selected the string

some class" href="mailto:email@example.com

Thanks to you all, though (btw, I am sorry, I always try to look for
help in the manual, but I didn't know the english term to search, in
this case: "h non-greedy")
and thanks to Tom that made me know \{-} , "\zs" and "\ze", I figured
out the expression

s/".\+:\zs[^"]\{-}@.\{-}\ze"/email@example.com

I just added the .\+: not to select the mailto: part and instead to
use an "all caracter" non-greedy, I used a "not a double-quote
character" non-greedy to select the first part of the email.
To use the same for the second part was superfluous since the last
double quote would stop the search, being the following characters non-
greedy themselves.

Thank you all again, I learned so much today. :)

--
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

No comments:

Post a Comment