Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: How can I reduce this with a REGEX?

by misterperl (Pilgrim)
on Mar 14, 2014 at 17:06 UTC ( [id://1078366]=note: print w/replies, xml ) Need Help??


in reply to Re: How can I reduce this with a REGEX?
in thread How can I reduce this with a REGEX?

..appreciate it guys but I'm trying to make this solution simpler & shorter- not longer!

This isn't too bad I spose.. Seems to work in a 1-liner:
s/(\d\d)((-\d\d)*?)(-\1)/$1$2/g while /(\d\d).*(-\1)/;
  • Comment on Re^2: How can I reduce this with a REGEX?

Replies are listed 'Best First'.
Re^3: How can I reduce this with a REGEX?
by hazylife (Monk) on Mar 15, 2014 at 10:47 UTC
    Which can probably be further reduced to:
    $ cat 1078350.in 12-12 12-12-12 12-13-12-13 12-12-13-13 12-13-13-14 $ perl -pe '1 while s/(\d\d)(.*?)(?:-\1)/$1$2/g' 1078350.in 12 12 12-13 12-13 12-13-14
      $ perl -pe '1 while s/(\d\d)(.*?)(?:-\1)/$1$2/g' 1078350.in thanks I like this construct, never saw it before.. You got my ++ vote...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-19 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found