Regex to change multiple lines

Tim Chase python.list at tim.thechases.com
Thu Sep 3 10:27:14 EDT 2020


On 2020-09-03 16:10, Termoregolato wrote:
> -- original
> This is the %%text that i must modify%%, on a line, %%but also
> on the others%% that are following
> 
> I need to change to
> 
> -- desidered
> This is the <del>text that i must modify</del>, on a line, <del>but
> also on the others</del> that are following

Should be able to use

 :%s/%%\(\_.\{-}\)%%/<del>\1<\/del>/g

It simplifies slightly if you use a different delimiter

 :%s@%%\(\_.\{-}\)%%@<del>\1</del>@g

-tim





More information about the Python-list mailing list