Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: A regex that only matches at offset that are multiples of a given N?

by 7stud (Deacon)
on Feb 14, 2013 at 19:49 UTC ( #1018775=note: print w/ replies, xml ) Need Help??


in reply to Re^2: A regex that only matches at offset that are multiples of a given N?
in thread A regex that only matches at offset that are multiples of a given N?

Your second regex works,

I'm not seeing that:

use strict; use warnings; use 5.010; # 0 5 10 15 20 25 30 35 # ' ' ' ' ' ' ' ' $_ = q{....fred1....fred2...fred3....fred4..}; while (/fred(?(?{ pos % 4 != 0 })(?!))(....)/sg) { } --output:-- Use of uninitialized value in numeric ne (!=) at (re_eval 1) line 1. Use of uninitialized value in numeric ne (!=) at (re_eval 1) line 1. Use of uninitialized value in numeric ne (!=) at (re_eval 1) line 1.


Comment on Re^3: A regex that only matches at offset that are multiples of a given N?
Download Code
Re^4: A regex that only matches at offset that are multiples of a given N?
by smls (Friar) on Feb 14, 2013 at 21:16 UTC

    Ah yes, you need to add parenthesis after the pos (to make sure it is interpreted as a function without parameters):

    /fred(?(?{ pos() % 4 != 0 })(?!))(....)/sg

    I fixed that locally while testing ikegami's regex but then forgot about it when reporting back, sorry.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (17)
As of 2015-07-01 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (19 votes), past polls