Jenda has asked for the wisdom of the Perl Monks concerning the following question:
I'm using a slightly modified code from perlre to extract the parameters to a method call in VB, that is , to match the contents of properly nested braces, skipping the braces found in VB-style string constants and I found something strange. It seems I cannot use my, for the $braces variable. Try the following code with and without the "my":
I getmy $braces = qr{ \( (?: (?> [^\(\)"]+ ) # Non-parens without backtracking | (?> "[^"]*")+ # skip string constants | (??{ $braces }) # Group with matching parens )* \) }x; my $Braces = qr{\(((?:[^\(\)"]+|"[^"]*")*(?:$braces(?:[^\(\)"]+|"[^"]* +")*)*)\)}; my $str = 'foo( FieldName, trim(CStr(Request.Form(FieldName))), Countr +yId )'; $str =~ $Braces and print "YES: $1\n" or print "NO!\n";
with the "my" andYES: CStr(Request.Form(FieldName))
without "my" withYES: FieldName, trim(CStr(Request.Form(FieldName))), CountryId
running under Win2k Server SP4This is perl, v5.8.0 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2002, Larry Wall Binary build 805 provided by ActiveState Corp. http://www.ActiveState. +com Built 18:08:02 Feb 4 2003
Is this a known bug, my misunderstanding, something that did not bite anyone yet, ...?
Thanks, Jenda
|
We'd like to help you learn to help yourself Look around you, all you see are sympathetic eyes Stroll around the grounds until you feel at home -- P. Simon in Mrs. Robinson |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (??{...}) in regexps and lexicals
by bart (Canon) on Jan 03, 2005 at 13:42 UTC | |
by Jenda (Abbot) on Jan 03, 2005 at 13:45 UTC | |
|
Re: (??{...}) in regexps and lexicals
by dave_the_m (Monsignor) on Jan 03, 2005 at 19:30 UTC | |
by Jenda (Abbot) on Jan 03, 2005 at 20:02 UTC |