简体   繁体   English

在记事本++行尾添加一个字符

[英]Add a character at the end of line in notepad++

I am using notepad++ and RegEx. 我正在使用notepad ++和RegEx。

I have a SRT file and I want to add three question marks "???" 我有一个SRT文件,我想添加三个问号“ ???” whenever the first the three characters of a line are also three questions marks "???". 每当一行的前三个字符也是三个问号“ ???”时。 However, I only wish to do this if the next line is blank. 但是,我只希望在下一行为空白的情况下执行此操作。 However, if the next line is not blank then I would like to add the ??? 但是,如果下一行不是空白,那么我想添加???。 after the end of that next line. 在下一行的结尾之后。

For example this is that I have. 例如,这就是我所拥有的。

14
01:04:21,406 --> 01:04:24,887
??? Face I'd never see again

15
01:04:24,885 --> 01:04:27,638
??? It's a shame to awake
in a world of pain

Now I would like to add the ??? 现在我想添加??? like this to both the lines. 两条线都这样。

14
01:04:21,406 --> 01:04:24,887
??? Face I'd never see again ???

15
01:04:24,885 --> 01:04:27,638
??? It's a shame to awake
in a world of pain ???

Notepad++ used to have problems with multiline matches, but the current releases are said to support Perl-style regexes much better. Notepad ++过去在多行匹配方面存在问题,但是据说当前版本更好地支持Perl风格的正则表达式。 I don't have Notepad++ installed, but if its regex engine works correctly, then the following regex should solve your problem: 我没有安装Notepad ++,但是如果它的正则表达式引擎正常工作,那么以下正则表达式应该可以解决您的问题:

Search for (?s)^(\\?{3}.*?(?=\\r?\\n\\r?\\n|\\z)) and replace with \\1??? 搜索(?s)^(\\?{3}.*?(?=\\r?\\n\\r?\\n|\\z))并替换为\\1??? .

Explanation: 说明:

(?s)         # Turn on dot-matches-all mode
^            # Match start of line
(            # Match and capture (group 1)
 \?{3}       # Three question marks
 .*?         # Any number of characters, as few as possible
 (?=         # until the following regex can be matched at the current position:
  \r?\n\r?\n #  Either two newlines in a row
 |           # or
  \z         #  the end of the file
 )           # End of lookahead assertion
)            # End of capturing group 1

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

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