Slashes and hashes in Perl and metacharacters

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

    When you build a regexp, you define a character as a delimiter for your regexp i.e. doing // or ##.
    If you need to use that character inside your regexp, you will need to escape it so that the regexp engine does not see it as the end of the regexp.

    If you build your regexp between forward slashes /, you will need to escape the forward slashes contained in your regexp, hence the escaping in your second example.

    Of course, the same rule apply with any character you use as a regexp delimiter, not just forward slashes.

提交回复
热议问题