Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Simple regex question

by gmax (Abbot)
on Oct 23, 2003 at 13:15 UTC ( [id://301573]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ perl -e '$_="aaabbccccddeee"; print $1,$/ while /((.)\2*)/g'
    #                                                  ^^
    ...
    cccc
    dd
    eee
    
  2. or download this
     push @array, $1 while  /((.)\2*)/g;
    
  3. or download this
    # THIS IS WRONG
    @array = $_ =~ /((.)\2*)/g;
    print join ", " , map {"<$_>"} @array;
    __END__
    <aaa>, <a>, <bb>, <b>, <cccc>, <c>, <dd>, <d>, <eee>, <e>
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found