vishnu.prasad has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to match COPYRIGHT(C) inside a regular expression but i am not able to match it. When i remove the paranthesis i am able to do the matching. Could someone help me ?? regards, Vishnu

Replies are listed 'Best First'.
Re: regex problem
by toolic (Bishop) on Jan 04, 2011 at 14:25 UTC
    One way to escape the parentheses is to use \Q
    use warnings; use strict; while (<DATA>) { print if /\QCOPYRIGHT(C)/ } __DATA__ foo COPYRIGHT(C) bar COPYRIGHT

    prints:

    foo COPYRIGHT(C)

    See also quotemeta

Re: regex problem
by Corion (Patriarch) on Jan 04, 2011 at 14:23 UTC

    See perlre. Parentheses are special within regular expressions.

Re: regex problem
by Fletch (Bishop) on Jan 04, 2011 at 14:23 UTC

    As anyone can clearly see from the sample you've provided of the code you've tried that's not working the problem is on line 17.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.