Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Another puzzled RegEx Problem.

by ikegami (Patriarch)
on Sep 12, 2007 at 13:29 UTC ( [id://638546]=note: print w/replies, xml ) Need Help??


in reply to Another puzzled RegEx Problem.

Like the error message says, a limitation of (?<=re) and (?<!re) is that re must only match expressions of a known, fixed length. That means you can use ?, *, +, etc in re. Basically, the regexp engine needs to know how many characters to look back.

Some alternatives:

$d =~ s/(\d\d)(?=\d)/$1-/g;
1 while $d =~ s/(?<=\d\d)(?=\d)/-/;
$d = reverse($d); $d =~ s/(?<=\d)(?=(\d\d)+$)/-/g; $d = reverse($d);

Update: Added solutions.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-25 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found