Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: A regex question.

by Athanasius (Archbishop)
on Aug 01, 2015 at 03:23 UTC ( [id://1137091]=note: print w/replies, xml ) Need Help??


in reply to Re^2: A regex question.
in thread A regex question.

Hello FeistyLemur, and welcome to the Monastery!

See the section “Global matching” in perlretut#Using-regular-expressions-in-Perl, and in particular note the following (emphasis added.):

In scalar context, successive invocations against a string will have //g jump from match to match, keeping track of position in the string as it goes along....
A failed match or changing the target string resets the position.... The current position in the string is associated with the string, not the regexp.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^4: A regex question.
by FeistyLemur (Acolyte) on Aug 02, 2015 at 05:15 UTC

    Yes, I understand now why I was seeing the behavior in question. Things are working as I intended in my script. I just wanted to understand what I was missing about the match operator. I didn't realize the position in the string was associated with the string and not the regexp.

    I got the answer I was looking for and understand the match operator better now, thanks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-03-19 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found