Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Does the match quit once it finds the first occurence of one of the alternatives ? e.g. in this case it finds a match on dog so exits$text = "The dog is black cat is white and the fox does not like the c +ow or pig"; if ($text =~ /(dog|cow|pig)/) { print "match found" }
Will that then try and match each alternative in the string and then return ?/(dog|cat|fox|cow|pig)/g
Can I do that using the alternation (dog|cat|fox|cow|pig) ?The dog is black cat is white and the fox does not like the cow or pig
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Understanding alternation
by g0n (Priest) on Feb 03, 2006 at 15:06 UTC | |
by McDarren (Abbot) on Feb 03, 2006 at 15:15 UTC | |
by Anonymous Monk on Feb 03, 2006 at 15:38 UTC | |
|
Re: Understanding alternation
by wfsp (Abbot) on Feb 03, 2006 at 15:57 UTC | |
|
Re: Understanding alternation
by glasswalk3r (Friar) on Feb 03, 2006 at 15:47 UTC | |
by Limbic~Region (Chancellor) on Feb 03, 2006 at 16:01 UTC |