Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 在记事本的行尾添加一个字符++;_Regex_Replace_Notepad++ - Fatal编程技术网

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

Regex 在记事本的行尾添加一个字符++;,regex,replace,notepad++,Regex,Replace,Notepad++,我正在使用记事本++和正则表达式 我有一个SRT文件,我想添加三个问号“?”,只要一行的前三个字符也是三个问号“?”。不过,我只希望在下一行为空时这样做。但是,如果下一行不是空的,那么我想添加???在下一行结束后 例如,这就是我所拥有的 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

我正在使用记事本++和正则表达式

我有一个SRT文件,我想添加三个问号“?”,只要一行的前三个字符也是三个问号“?”。不过,我只希望在下一行为空时这样做。但是,如果下一行不是空的,那么我想添加???在下一行结束后

例如,这就是我所拥有的

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
现在我想补充一下???两条线都是这样

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++过去在多行匹配方面存在问题,但据说目前的版本更好地支持Perl风格的正则表达式。我没有安装Notepad++,但是如果它的正则表达式引擎工作正常,那么下面的正则表达式应该可以解决您的问题:

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

说明:

(?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

谢谢,帮了大忙。做了之后,我发现有些情况下我不想添加???即使是从一开始。而是将其添加到下一行。区别因素是如果一行以???并且下一行不是空的,那么我想添加一下???在下一行,而不是第一行,以???有什么办法吗?太神奇了。多谢各位much@user1742965:很高兴听到这个消息。欢迎来到StackOverflow,我希望你会发现它和我一样是一个很好的资源。