in reply to Re: Regular Expression problem with $variable =~ m/C++/
in thread Regular Expression problem with $variable =~ m/C++/

Thank you, 'quotemeta' is a very good solution. I have also tried already the use of \Q...\E.

You are right when you speak (for example) about 'c' letter in Visual Basic. Fortunately I have to compare always complex names that are never included in other name.
Thank you for your support!
  • Comment on Re^2: Regular Expression problem with $variable =~ m/C++/

Replies are listed 'Best First'.
Re^3: Regular Expression problem with $variable =~ m/C++/
by ikegami (Patriarch) on Jun 12, 2007 at 16:35 UTC
    You might find the following useful:
    my @matches = grep { ",$Array[$_]," =~ /,\Q$VarString\E,/i } 0..$#Arra +y;

    @matches will contain the indexes (0, 1, 2 and/or 3) or the elements of @Array that contains the matching substrings. The commas ensure C won't match VISUAL BASIC, and the i ensures Perl will match PERL.

    If the same item won't appear in two array elements, then you can use the following version to store the index in $match:

    my ($match) = grep { ",$Array[$_]," =~ /,\Q$VarString\E,/i } 0..$#Arra +y;