正则表达式将新行和空格替换为太空

时间:2019-05-18 13:58:08

标签: regex pspad

我有一个这样的字符串

-U, --update                     Update this program to latest version. Make
                                 sure that you have sufficient permissions
                                 (run with sudo if needed)
-i, --ignore-errors              Continue on download errors, for example to
                                 skip unavailable videos in a playlist
--abort-on-error                 Abort downloading of further videos (in the
                                 playlist or the command line) if an error
                                 occurs

我的目标是将其转换为此:

-U, --update                     Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)
-i, --ignore-errors              Continue on download errors, for example to skip unavailable videos in a playlist
--abort-on-error                 Abort downloading of further videos (in the playlist or the command line) if an error occurs

使用正则表达式。

我假设

-U, --update                     Update this program to latest version. Make
                                 sure

-U, --update Update this program to latest version. Make +换行+一定数量的空格相同。因此,要替换它,我需要用空格替换新行\n +()。

但是它不能代替它。

什么是正确的正则表达式(我正在使用pspad)

1 个答案:

答案 0 :(得分:0)

我不知道pspad的细微差别,但是以下查找和替换似乎有效:

Find: \n[ ]+
Replace: (nothing)

Demo

请注意,上述模式只会在换行符的末尾匹配换行符,后接续行符,并在换行符开头填充一个或多个空格。在给定的说明中,该模式与最后一行匹配。