For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > August 2004 > brackets in regular expression problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author brackets in regular expression problem
lucky8

2004-08-19, 4:00 am

Can anyone explain the following behaviour?
When I run the script below the results of bracket matches are different:
"1 2" and "12"
------------------------

$_ = '123';

if(/(1|12)(2?)/)
{
print "$1 $2\n";
}

if(/(12|1)(2?)/)
{
print "$1 $2\n";
}
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com