in reply to Re: Re: Re: Re: Re: Re: my versus our in nested regex
in thread my versus our in nested regex
I think my vision of the way it would work is that a named capture would get stored exactly the same as if
(...)(?{ $var = $^N })
That is to say, if a lexical named $var was in scope, it would get the captured string, else a global of that name would. If two blocks named the same var, the second would override the first just as with normal assignment.
I've no idea what the dotNet syntax is (or even that it had such), but Enlil and I had a discusion about it somewhere a few months ago. Unfortunately, it was tucked down in teh bowels of a thread with an unrelated name, so I can't find it right now.
Off the top of my head, I think that
(?$var:...)
would work. I don't think it would conflict with anything else?
The one distinction I would make is that if an array was given rather than a scalar,
(?@array:...){1,10}
then the captured string would be pushed onto the array. This would allow for captures with repeatition specifiers to do something sensible.
Perhaps harder to think through is what happens when a regex backtracks through a capture. undef the $var and pop the @array maybe?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Re: Re: my versus our in nested regex
by demerphq (Chancellor) on Oct 18, 2003 at 21:41 UTC | |
by BrowserUk (Patriarch) on Oct 18, 2003 at 22:30 UTC | |
by demerphq (Chancellor) on Oct 19, 2003 at 00:08 UTC |