Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^7: Regex fun

by ikegami (Patriarch)
on Dec 16, 2009 at 00:55 UTC ( [id://812960]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Regex fun
in thread Regex fun

it seems to me specifically to be saying that you can't use a variable there.

Then why did the OP say "Can't use a \x variable" instead of "can't use a variable"?

If I say "The Western sky is orange", doesn't that tell you something about the Eastern sky? At the very least, I'm leaving the possibility of the Eastern sky being a different colour. In fact, it's quite likely it's either a different colour or I don't know it's colour.

capture buffers (which I guess means $1 instead of \1?)

I mean "what is captured". Technically, they exist as a reference to the string being matched, a start position and an end position (or something similar).

$1 and \1 are both windows into them, and so are @-, @+, %-,%+ and $^N.

since their values don't change during the regex match

They're not used at all during regex matching. There isn't even a regex opcode to refer to them. The only way they can be accessed is via \1 (etc) and via Perl code blocks ((?{ }) and (??{ }). Neither of those can be used in a quantifier.

And if they don't change — if you can't even give them a value — how can you consider them variables?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://812960]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-24 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found