Wednesday, December 23, 2020

Re: Substitute pattern over multiple lines

On Wed, Dec 23, 2020 at 10:07:26PM -0400, John Cordes wrote:
>
> On Wed, Dec 23, 2020 at 9:31 PM Tim Chase <vim@tim.thechases.com> wrote:
>
> On 2020-12-23 20:39, John Cordes wrote:
> >> I'd start with this ugly monstrosity:
> >>
> >> :%s/^2 \u\{3,} \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div
> >> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> >> 'g'), '\n', '', 'g')."<\/div>\n"

> :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs…
>
> Hope this helps get you on the right path,
>
> -tim
>
> This is amazing looking, Tim -- thanks so much! There is a lot for a nearly
> 80-year old to unpack here -- it's going to take me a while. :)
> It looks as though you have covered all the bases I want to deal with.
>
> Thank you again,
> John

Just a quick report to say that following your suggestion above leads to:

:g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC \).*\n\)\+\)/\='<div class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '', 'g'), '\n', '', 'g')."<\/div>\n"

which as far as I can tell at the moment is working perfectly,
handling all situations the way I wanted. I will check further and
also test on another GEDCOM file when I'm fresher.

Thanks again Tim; I have learned a lot. Now if it would only stick...

John

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201224023438.GA19170%40dal.ca.

No comments: