Hi Hsiu!

On Sa, 02 Mär 2013, Hsiu Dai wrote:

> Hi,
> 
> I'd like to change all the underscores within a class="____" to hyphens. For 
> instance, I have:
> 
> <a href="linkone" class="class_a class_b"></a> 
> <a href="link_two" class="classc class_d"></a> 
> 
> And in the end, I'd like to to be:
>  
> <a href="linkone" class="class-a class-b"></a> 
> <a href="link_two" class="classc class-d"></a> 
> 
> As you can see, the underscores have been changed to hyphens but only in the 
> class attribute, everywhere else they're left alone and everything else in 
> the class attribute is also left alone.
> 
> I thought maybe I could use a lookbehind for this, but am still having 
> trouble. I understand why the following doesn't work (the /g tries to match 
> the `class="` again and fails), but it's as close as I've gotten.
> 
> s/\(class="\)\@<=\([^"_]*\)_/\2-/g

That is pretty close. This should work:
s/\(class="\%([^"]*\)\)\@<=_/-/g

regards,
Christian
-- 
Hätte Gott gewollt, daß wir denken, so hätte er uns ein Gehirn gegeben.
Und hätte Gott gewollt, daß wir fliegen, hätte er uns Flugtickets gegeben.

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to