简体   繁体   中英

Remove/strip specific Html tag and replace using NotePad++

Here is my text:

<h3>#6</h2>
Is he eating a lemon?

</div>

I have a few of them in my articles the #number is always different also the text is always different.

I want to make this out of it:

<h3>#6 Is he eating a lemon?</h3>

I tried it via regex in notepad++ but I am still very new to this:

My Search:

<h3>.*?</h2>\r\n.*?\r\n\r\n</div> 

Also see here .

Now it is always selecting the the right part of the text.

How does my replace command need to look like now to get an output like above?

You should modify your original regex to capture the text you want in groups, like this:

<h3>(.*?)</h2>\r\n(.*?)\r\n\r\n</div>
    (   )         (   ) 
//  ^             ^     These are your capture groups

You can then access these groups with the \\1 and \\2 tokens respectively.

So your replace pattern would look like:

<h3>\1 \2</h3>

您的搜索可能是<h3>(.*)<\\/h2>\\r\\n(.*)\\r\\n\\r\\n<\\/div> ,替换为<h3>$1 $2</h3> ,其中$ 1和$ 2代表括号中捕获的字符串。

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