in reply to Re: pattern matching
in thread pattern matching
Here's what I would do:
if (/(\w\w)(?: (\w\w)(?: (\w\w)(?: (\w\w))?)?)?/) { # Do something }
I don't like the idea of making the parallel items optional, instead, I nest them, so $3 cannot match if $2 didn't match, as both are part of the same optional pattern. Ditto with $4, that can only match if both $3 and $2 matched.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: pattern matching
by vineet2004 (Initiate) on Dec 26, 2006 at 04:38 UTC | |
|
Re^3: pattern matching
by vineet2004 (Initiate) on Dec 26, 2006 at 07:23 UTC | |
by bart (Canon) on Dec 26, 2006 at 22:47 UTC |