Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Regular Expression problem with $variable =~ m/C++/

by ikegami (Patriarch)
on Jun 12, 2007 at 16:35 UTC ( [id://620758]=note: print w/replies, xml ) Need Help??


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

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://620758]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 12:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found