Hi,
 
I've been given some html which, oddly, is half in nicely quoted
attributes+values:
 
<span class="good">
 
and half not
 
<span class=bad>
 
I'm trying to write a regex to add quotes around the ones without. I can
do this in perl, but not in vim, and I'd like to know what I'm doing
wrong because I've run across this problem before.
 
This was my attempt:
 
:%s/=\([^"]\+\)\{-}\([ >]\)/="\1"\2/g
 
My reasoning:
 
=\([^"]\+\)             find and save stuff after an = that does not
have a "
\{-}                    I've never used this before, just found it
online, at first it seemed to do what I want it to do, make the \+
evaluation lazy
\([ >]\)                find and save either the space or > after the
attribute value
 
It half works, but sometimes skips spaces and I get <tag attrib1="blah
attrib2=duh">
 
Any advice would be appreciated. Perhaps I'm not using \{-} correctly?

Reply via email to