Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2014-09-19 19:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (144 votes), past polls