[英]Notepad++ regular expressions and replace
I have a couple of sentences that need processing using regular expressions. 我有几句话需要使用正则表达式进行处理。 They're in a text file and I'm opening it in notepad++. 它们在一个文本文件中,而我正在用记事本++打开它。
<tag>There are two tags here</tag>
<tag>How am i supposed to
feel when this is happening?</tag>
<tag>I'm not sure.
But oh well<tag>
Is it possible to use notepad++'s regular expressions and replace functionality to produce an output like so: 是否可以使用notepad ++的正则表达式并替换功能以产生如下输出:
<tag>There are two tags here</tag>
<tag>How am i supposed to feel when this is happening?</tag>
<tag>I'm not sure. But oh well<tag>
So that sentences that span over two or more lines are joined based on the fact that there is a >
at the end of the sentence. 因此,基于句子末尾有一个>
的事实,可以将跨越两行或更多行的句子连接起来。 Thanks. 谢谢。
Replace this: 替换为:
[\r\n]+(?!<)
with a space 与空间
Explanation: 说明:
[\\r\\n]+
- matches 1+ occurrences of a \\r
or \\n
[\\r\\n]+
-匹配1次以上的\\r
或\\n
(?!<)
- negative lookahead to validate that the above match is not followed by an opening tag <
(?!<)
- 否定超前,以确认上面的匹配项后没有开头标签<
Before Replacement with space: 在用空格替换之前:
After replacing the matches with space: 用空格替换匹配项后:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.