Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: regex question

by graff (Chancellor)
on Mar 23, 2004 at 02:15 UTC ( #338868=note: print w/replies, xml ) Need Help??


in reply to regex question

It's simple: split that line wherever there is a colon or semicolon followed by space -- just to be safe, we'll accept one or more whitespace characters of any kind:
my $fontline = "font-family: Verdana, Arial, Geneva, san-serif; font-s +ize: .69em; color: #666666"; my @components = split /[:;]\s+/, $fontline; print join "\n", "", @components, ""; print "\n or, as a hash:\n"; %components = @components; print "$_ => $components{$_}\n" for ( keys %components ); __OUTPUT__ font-family Verdana, Arial, Geneva, san-serif font-size .69em color #666666 or, as a hash: font-family => Verdana, Arial, Geneva, san-serif font-size => .69em color => #666666

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2022-08-12 15:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?