简体   繁体   English

使用正则表达式在包含某些内容的行之前插入文本(Notepad ++)?

[英]Using regex to insert text BEFORE a line containing something (Notepad++)?

I have several lines like this: 我有几行像这样:

Apples
__________
B
C

Bananas
___________
D
E

Carrots
____________
F 
G

I would like to make it so that Apples, bananas, and carrots are each their own separate heading in html. 我想这样做,以便苹果,香蕉和胡萝卜各自在html中各自独立。 So I would like to do a regex search for 3 consecutive underscores or more and then insert html heading tags in the line preceding it. 所以我想对3个连续的下划线或更多进行正则表达式搜索,然后在它前面的行中插入html标题标记。 Can someone tell me how to do this with Notepad++ regex search and replace? 有人可以用Notepad ++正则表达式搜索和替换告诉我如何做到这一点吗?

Search for 搜索

(^|\n)(.*)([\n\r]+)(_{3,})([\n\r]|$)

and replace it with 并替换它

$1<h1>$2</h1>$5

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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