Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Another puzzled RegEx Problem.

by artist (Parson)
on Sep 12, 2007 at 15:11 UTC ( #638593=note: print w/replies, xml ) Need Help??


in reply to Another puzzled RegEx Problem.

No solution here, but the challenge would be to find the solution that has
  • No while
  • No reverse
  • No $1 etc in substitution part
--Artist

Replies are listed 'Best First'.
Re^2: Another puzzled RegEx Problem.
by ikegami (Patriarch) on Sep 12, 2007 at 17:12 UTC

    No external loop, no reverse and nothing but "-" in the substitution part:

    $d =~ s/(?!^|$)(?(?{ pos() % 2 })(?!))/-/g;

    Update: Bug fix. I originally forgot to prevent "-" from being placed at the end.

      cool

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2022-12-10 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?