简体   繁体   中英

Using regex over several lines in notepad++

I am wanting to find the following set of html information in several hundred separate files:

{{> StartPageAvatar char="k"}}
<h3>{{> m1a35Intro}}</h3>
{{> duration3}}

No I can do all this separately with,

([^\w\*]{3,4 } StartPageAvatar char="([k,t,u,e,l]{1,4})"[^\w\*]{2})
(<h3>([^\w\*]{3,4 }m(.)a(.{1,2})Intro[^\w\*]{2})</h3>)
([^\w\*]{3,4 }duration(.)[^\w\*]{2})

What I cannot get is how to do all three lines at once, as I would like to use the variables m1a35 to add in a new line above the three original. So the end result I would like to have:

<h1 class="start-page-header">{{> m1a35Title}}</h1>
{{> StartPageAvatar char="k"}}
<h3>{{> m1a35Intro}}</h3>
{{> m1a33Time}}

So I am deleting the {{duration#}} template and replacing it with an activity specific time template. The problem I am having is adding in the {{> m1a33Title}} line, as this needs to know what activity numbers it should be, which is provided by the line below.

I just cannot get the three regex expressions made to work together and do it all in one go.

If I understood right, this regex will do the work:

(\W{3,4}StartPageAvatar char="[ktuel]{1,4}"\W{2}).<h3>(\W{3,4}m.a.{1,2})Intro\W{2}<\/h3>.\W{3,4}duration.\W{2}

Live Demo

I changed:

  • your char from [k,t,u,e,l] to [ktuel] (the comma isn't needed)
  • your negation [^\\w\\*] to \\W (but it missed the star)
  • removed a few useless capturing groups

Don't forget to set the find & replace options of N++ to :

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM