Slashes and hashes in Perl and metacharacters

前端 未结 6 1036
旧巷少年郎
旧巷少年郎 2020-12-22 01:32

Thanks for the previous assistance everyone!. I have a query regarding RegExp in Perl

My issue is..

I know, when matching you can write m// or // or ## (mus

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 01:54

    If you are not use slashes, the recommend practice is to use the curly braces and the /x modifier.

    $date=~ s{ (\d+) \/ (\d+) \/ (\d+) }{$1/$2/$3}x;
    

    Escaping the non-alphanumerics is also a standard even if they are not meta-characters. See perldoc -f quotemeta.

提交回复
热议问题