Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.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 如何使用prename从文件名中删除前导号码?_Regex_Perl - Fatal编程技术网

Regex 如何使用prename从文件名中删除前导号码?

Regex 如何使用prename从文件名中删除前导号码?,regex,perl,Regex,Perl,我有很多这样的文件 0678 - Puzzle Series Vol. 5 - Slither Link (J).nds 0679 - Puzzle Series Vol. 6 - Illust Logic (J).nds 0680 - Puzzle Series Vol. 7 - Crossword 2 (J).nds 我想去掉前导的四位数和破折号,这样它们就变成了 Puzzle Series Vol. 5 - Slither Link (J).nds Puzzle Series Vol.

我有很多这样的文件

0678 - Puzzle Series Vol. 5 - Slither Link (J).nds
0679 - Puzzle Series Vol. 6 - Illust Logic (J).nds
0680 - Puzzle Series Vol. 7 - Crossword 2 (J).nds
我想去掉前导的四位数和破折号,这样它们就变成了

Puzzle Series Vol. 5 - Slither Link (J).nds
Puzzle Series Vol. 6 - Illust Logic (J).nds
Puzzle Series Vol. 7 - Crossword 2 (J).nds
当我尝试使用prename时,我得到

问题:

有人能看出我做错了什么吗?这并不意味着你认为这意味着什么。这意味着前一个原子是可选的。例如/^ab?\z/匹配a和ab

使用。匹配除换行符以外的任何字符/s制造。任何字符、句号

s/.... - (.+nds)/$1/

s/.{4} - (.+nds)/$1/          # Readability improvement.

s/.{4} - (.+nds)/$1/s         # No need to prevent `.` from matching a LF.

s/^.{4} - (.+nds)/$1/s        # Better to anchor for readability if nothing else.

s/^\d{4} - (.+nds)/$1/s       # A bit more restrictive, and more self-documenting.

s/^\d+ - (.+nds)/$1/s         # Do we really need to check that there are exactly 4?

s/^\d+ - (.*)/$1/s            # No point in checking if `nds` is contained.

s/^\d+ - //
??这并不意味着你认为这意味着什么。这意味着前一个原子是可选的。例如/^ab?\z/匹配a和ab

使用。匹配除换行符以外的任何字符/s制造。任何字符、句号

s/.... - (.+nds)/$1/

s/.{4} - (.+nds)/$1/          # Readability improvement.

s/.{4} - (.+nds)/$1/s         # No need to prevent `.` from matching a LF.

s/^.{4} - (.+nds)/$1/s        # Better to anchor for readability if nothing else.

s/^\d{4} - (.+nds)/$1/s       # A bit more restrictive, and more self-documenting.

s/^\d+ - (.+nds)/$1/s         # Do we really need to check that there are exactly 4?

s/^\d+ - (.*)/$1/s            # No point in checking if `nds` is contained.

s/^\d+ - //

你能给我换行吗?是否出现在文件名中?是,LF表示换行U+000A。是的,unix系统上的文件名在技术上可以包含NUL字节00和/或目录分隔符以外的任何内容。Windows的限制性更强。当然,没有人故意使用它们。我只是不想排除LF,除非我有理由这样做。为什么不花时间检查换行符呢?换句话说,我在模式中默认使用/s,并且我认为省略/s是故意检查换行符。是否可以使用LF换行符?是否出现在文件名中?是,LF表示换行U+000A。是的,unix系统上的文件名在技术上可以包含NUL字节00和/或目录分隔符以外的任何内容。Windows的限制性更强。当然,没有人故意使用它们。我只是不想排除LF,除非我有理由这样做。为什么不花时间检查换行符呢?换句话说,默认情况下,我在带的模式中使用/s,我认为省略/s是故意检查换行符。下面的命令应该删除前导4位prename的/^\d{4}-/'*.nds。下面的命令应该删除前导4位prename的/^\d{4}-/'*.nds。