$_ = '123'; if(/(1|12)(2?)/) { print "$1 $2\n"; } if(/(12|1)(2?)/) { print "$1 $2\n"; } [download]
In reply to brackets matching problem by lucky8