Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: string manipulations.

by GrandFather (Saint)
on Nov 23, 2006 at 10:05 UTC ( [id://585697]=note: print w/replies, xml ) Need Help??


in reply to string manipulations.

Or as an array of arrays:

use strict; use warnings; $| = 0; my $str="A: Gold, Black, Purple, Blue, Red B: Black, Neon Pink, Ne +on Yellow, Neon Green, Neon Purple, Red, White, Neon Orange, Navy"; my @records; my @strings = $str =~ m/(\w+:(?:(?!\b\w+:).)*)/g; push @records, map {[m/(\w+:)/, m/(?<=:|,)\s([^,]*,?)/g]} @strings; print "@$_\n" for @records;

Prints:

A: Gold, Black, Purple, Blue, Red B: Black, Neon Pink, Neon Yellow, Neon Green, Neon Purple, Red, White, + Neon Orange, Navy

DWIM is Perl's answer to Gödel

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-23 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found