Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Elegant way to split into sequences of identical chars?

by eric256 (Parson)
on Nov 30, 2005 at 16:25 UTC ( #512985=note: print w/replies, xml ) Need Help??


in reply to Re: Elegant way to split into sequences of identical chars?
in thread Elegant way to split into sequences of identical chars?

Forgot to post my solution early, but its similar to yours so i'll add it here.

use Data::Dumper; my $test = "xx556xxyyy"; my @matches ; push @matches, $1 while ($test =~ /((.)\2*)/g); print Dumper(@matches);

These solutions have the added benefit of being able to switch to just a list of chars by changeins $1 to $2. Not sure thats of any use but hey. lol. I'm mildly suprised there is no regex command to match last char, or a way to specify which groups to return and with are just used internal to the regex, I guess the need doesn't arise that often.


___________
Eric Hodges $_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9'; s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2019-05-24 16:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (150 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!