Friday, September 2, 2011

Re: How do I capitalize text bewteen HTML tags?

On 09/02/11 11:29, tplarkin7 wrote:
> I then used VIM to capitalize the text since ordinary regex does not have
> that ability.
>
> For those that can't see the code I posted, it is visible in VIM's forum.

Ah, you're posting through Nabble which doesn't seem to pass
along the HTML to the official Vim list (vim@vim.org, mirrored at
vim_use@googlegroups.com).

Pulling in the source from the URL in your Nabble email I get the
following:

>
> This post was updated on .
> I would like to capitalize the words, "Narrator (v.o.)" between the paragraph tags below:
>
> <P STYLE="margin-left: 2in; margin-bottom: 0in">Narrator
> (v.o.)</P>
>
>
> I need to keep the entire tag as shown. For example, other tags have a margin of 1in, and I don't want to capitalize between them.
>
> Another issue is the hard return after "Narrator". Some of the lines in my HTML file have no return such as the line below:
>
> <P STYLE="margin-left: 2in; margin-bottom: 0in">Aristobulus</P>
>
>
> Thanks for your help!
>
> EDIT:
> I'm slowly figuring this out:
>
> I've successfully capitalized the following example:
>
> Before code:
>
> <P ALIGN=CENTER>Narrator (v.o.)</P>
>
>
> After code:
>
> <P ALIGN=CENTER>NARRATOR (V.O.)</P>
>
>
> Code used:
>
> :%s:\(<P ALIGN=CENTER>\)\(.*\)\(<\):\1\U\2\3:g
>
>
> I attempted the same for
>
> <P STYLE="margin-left: 2in; margin-bottom: 0in">Aristobulus</P>
>
>
> But, it gave me an error.

You don't give the error or the command you gave, so it's hard to
track down what went wrong. I'd try something like

:%s/\c<P style="[^"]*2in[^"]*"[^>]*>\zs\_[^<]*\ze</\U&/g

It has odd edge-cases where you might have nested tags, but it
should handle most of the cases.

-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

No comments: