I think I can parse this regex:

qr/x          #match one 'x'
.{1,4} #followed by no less than one but no more than four of anything
     \d\d     #followed by 2 digits.
     x|a      #followed by an 'x' or an 'a'
    /x;

You're string looks like

" x11x  x22x a"

So if we march through the above:
   match 'x'
   1-4 of anything followed by 2 digits, so...
   (x1)1x<-- Second one isn't a digit
   (x11)x<-- First one isn't a digit
   (x11x) <-- Space isn't a digit
(x11x )x<--Hmm, x isn't a project either, that's the end of our 1-4 matches of anything

If you keep marching through the string like this you'll see that the first match is (the part in the parens)
x11(x x22)x a

I think you would want to either include '0' in the {} or get rid of that part altogether from looking at your test data.


On Jun 26, 2006, at 10:28 AM, tom arnall wrote:

    11 #with '.{1,4}'                           
    12 $re1 = qr/x.{1,4}\d\dx|a/;
    13 $re2 = qr/($re1\s)?$re1/;
    14 ($f) = /($re2)/;                         
    15 print "f:$f\n";

HTH,
Peter Cornelius
Sr. Applications Engineer
LiveOps Inc. (http://www.liveops.com)

Reply via email to