On Mon, 30 Jan 2006 10:26:51 -0500, Chas Owens wrote
> On 1/30/06, Keith Worthington <[EMAIL PROTECTED]> wrote:
> snip
> > Wow, it is going to take me some time to wrap my head around this 
> > code.  I really like the commenting idea.  That certainly will 
> > help the next time around.  I don't get the lines where you 
> > defined the pattern. i.e. my $border = qr{ cool_pattern_stuff }xi
> > Hmm is qr something special?  I guess I will start with the x 
> > modifier man page.
> snip
> 
> Yes, it is the "quote regex" operator.  It takes a string and returns
> a compiled regex.  You can read more at "perldoc perlop" and "perldoc
> perlre".

Chas,

Well, I am having some fun with this qr{} now. :-)  I created the two pattern
matches and then threw the result into my expression.  Absolutely amazing!  
Woohoo! 

The only challenge is that the $p_number pattern seems to match all of the
following.
10 1/2
10-1/2
10--1/2

I started out with (\s+|-?) as my delimiter pattern and then when that didn't
work I changed it to (\s+|-{1,1}).  It still matches the case with two hyphens.
 Can you tell me why?

my $p_fraction = qr{                 # match a fractional number
                     ($RE{num}{int}) # integer pattern
                     (/)             # fraction delimiter
                     ($RE{num}{int}) # integer pattern
                   }x;

my $p_number = qr{                       # match a number
                     (
                        ($RE{num}{real}) # real pattern
                           |
                        ($RE{num}{real}) # real pattern
                        (\s+|-{1,1})     # mixed number delimiter
                        ($p_fraction)    # fraction pattern
                           |
                        ($p_fraction)    # fraction pattern
                     )
                 }x;

if ($v_size_str =~ /$p_number\s*['"]\s*x\s*$p_number['"]/i){

Kind Regards,
Keith

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to