Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

(golf) Collapse repetitions within a string

by Corion (Patriarch)
on Jun 25, 2003 at 11:55 UTC ( [id://268820]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    foofoofoo              -> Sequence is foo
    123456                 -> no Sequence
    ooofoofoofoof          -> First sequence is o
    
  2. or download this
    foofoofoofoo           -> foo repeated 4 time(s)      # correct
    foofoofoofoo           -> foofoo repeated 2 time(s)   # wrong
    
  3. or download this
    123456                 -> 123456
    
  4. or download this
    foo repeated 2 time(s)
    o
    f
    o repeated 3 time(s)
    
  5. or download this
    perl -nle 'printf(defined $3
                        ? "%s\n"
    ...
                 $1.$3,
                 length($2)/length($1.$3)+1)
               while/(?:(\w+?)(\1+))|(?:(\w+?)(?!\3))/g'
    
  6. or download this
    __END__
    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ;    # The  
    $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider
    ($c = $d->accept())->get_request(); $c->send_response( new   #in the
    HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' #  web
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://268820]
Approved by broquaint
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-23 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found