In asking my question for clarification I belive I have answered myself but anyway:
Can I have some clarification on the wonderful line:
As I understand it the brackets are use to return the values as $1, $2 .. $9my %prices = $str =~ m/((?:$animal)s?)\s(?:is|are)\s(\$\d+)/g;
It looks like (?: .. ) is something special and is not returning a numbered variable so all we get out are two variables $1 and $2 used respectively in the hash as the key and value?
I have often wanted to check to see if a string contains one of multiple sub-strings.. I assume I could do it like this:
Woo Hoo!use strict; my $something = 'This is a bang of a bing thing'; if($something =~ m/((?:bing|bong|bang))/i) { print "Found '$1' in '$something'\n"; }
It returned the first one found.. which is fair.. I wonder if this could return all matches found, in this case 'band' and 'bing'?Found 'bang' in 'This is a bang of a bing thing'
And could I check for a string contain anything from a list?
naturally does not work :-(... my @list = qw / bing bong bang /; if($something =~ m/(?:@list)/i) ...
thanks
___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com
In reply to Re: Re: Another regexp question
by wolis
in thread Another regexp question
by carric
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |