Regex: How to remove extra spaces between strings in Perl

前端 未结 5 442
不知归路
不知归路 2021-01-18 10:03

I am working on a program that take user input for two file names. Unfortunately, the program can easily break if the user does not follow the specified format of the input.

5条回答
  •  时光说笑
    2021-01-18 10:20

    You'll need to trim spaces before handling the filename data in your routine, you could check the file extension with yet another regular expression, as nicely described in Is there a regular expression in Perl to find a file's extension?. If it's the actual type of file that matters to you, then it might be more worthwile to check for that instead with File::LibMagicType.

提交回复
热议问题