【发布时间】:2020-07-03 12:04:22
【问题描述】:
是否可以在 Notepad++ 中的每一行之后添加文本或 HTML 标记?
例如,这段文字:
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[COMPANY]</a></p>
Alexander Hamilton (Alexander Hamilton)
We are waiting in the wings for you (waiting in the wings for you)
You could never back down
You never learned to take your time!
Oh, Alexander Hamilton (Alexander Hamilton)
When America sings for you
Will they know what you overcame?
Will they know you rewrote the game?
The world will never be the same, oh
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[BURR, MEN, & COMPANY]</a></p>
The ship is in the harbor now
See if you can spot him
Just you wait
Another immigrant
Comin’ up from the bottom
Just you wait
His enemies destroyed his rep
America forgot him
目标是让上面的文字变成这样:(添加break标签)
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[COMPANY]</a></p>
Alexander Hamilton (Alexander Hamilton)</br>
We are waiting in the wings for you (waiting in the wings for you)</br>
You could never back down</br>
You never learned to take your time!</br>
Oh, Alexander Hamilton (Alexander Hamilton)</br>
When America sings for you</br>
Will they know what you overcame?</br>
Will they know you rewrote the game?</br>
The world will never be the same, oh</br>
<p class="text-center mb-0 cfont"><a class="cfont" href="#tag">[BURR, MEN, & COMPANY]</a></p>
The ship is in the harbor now</br>
See if you can spot him</br>
Just you wait</br>
Another immigrant</br>
Comin’ up from the bottom</br>
Just you wait</br>
His enemies destroyed his rep</br>
America forgot him</br>
我之前使用<pre></pre>,但注意到文本换行后出现水平滚动并且无法使其消失,因此我将其丢弃并选择使用<br>标签。
我遇到的问题是每一行都没有可用于添加<br> 标签的“共同点”。因此,我希望可以有一个正则表达式技巧来做到这一点,比如在每行之后检测一个空格?
不一定要一次性完成,我只是希望有一种更快的方法。
一个附带问题:有没有办法在这些纯文本的每一行添加id 或class 而无需添加<a> 或<p> 标签?
提前非常感谢!
【问题讨论】:
-
也许寻找
(.+)(?<!>)$并替换为\1</br>