Slashes and hashes in Perl and metacharacters

前端 未结 6 1039
旧巷少年郎
旧巷少年郎 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

    The forward slashes are not meta characters in themselves - only the use of them in the second example as expression separators makes them "special".

    The format of a substitute expression is:

    s
    

    In the first example, using a hash as the first character after the =~ s, makes that character the expression separator, so forward slash is not special and does not require any escaping. in the second example, the expression separator is indeed the forward slash, so it must be escaped within the expressions themselves.

提交回复
热议问题