![在与特定模式匹配的单词后添加新行](https://linux22.com/image/1382234/%E5%9C%A8%E4%B8%8E%E7%89%B9%E5%AE%9A%E6%A8%A1%E5%BC%8F%E5%8C%B9%E9%85%8D%E7%9A%84%E5%8D%95%E8%AF%8D%E5%90%8E%E6%B7%BB%E5%8A%A0%E6%96%B0%E8%A1%8C.png)
我正在尝试在 Notepad++ 中的连字符单词(一个或多个连字符)之前和之后添加新行
输入
This is a search-and-replace test which I need-help to figure-out</h2>
输出
This is a
search-and-replace
test which I
need-help
to
figure-out
答案1
这应该可以让你:
在 Notepad++ 中按CTRL+H并输入
寻找:
(\w+(-\w+)+\s+)|(\w+(-\w+)+[^\r\n])
代替:
\r\n\1\r\n
(需要在末尾用 \r\n 匹配该单词)