develooper Front page | perl.beginners | Postings from February 2012

Re: match

Thread Previous | Thread Next
From:
timothy adigun
Date:
February 17, 2012 22:49
Subject:
Re: match
Message ID:
CAEWzkh4mut8jhyEw967VB08zjy48gD6QxmsMfmohG=dgwskd8w@mail.gmail.com
Hi lina,
    Check one script that matchs what you want below:
On Sat, Feb 18, 2012 at 5:51 AM, lina <lina.lastname@gmail.com> wrote:

> How to make a match for the following?
>
> "V  c #767676 " /* "0.808" */,
> "W  c #6F6F6F " /* "0.846" */,
> "X  c #696969 " /* "0.885" */,
> "Y  c #626262 " /* "0.923" */,
> "Z  c #5C5C5C " /* "0.962" */,
> "a  c #555555 " /* "1" */,
> "b  c #4E4E4E " /* "1.04" */,
> "c  c #484848 " /* "1.08" */,
>
> I tried the
>
> /^\"([[:alpha:])\s+c\s+\#*\s\/\*\"(\d)*\"*/x
> $dict{$1} = $2;
>
   This works:
#!/usr/bin/perl
use warnings;
use strict;

while (<DATA>) {
    s/.
    (\w) # pick the single letter your $1
     \s+?\w\s
     \W
     .{6} # remove the 6 alpha-letter
     \s+?.+?
     (\d(\.\d+)?) # pick the needed digit your $2
    .*?$
    /$1$2/igmx;
    print $1, ' ', $2,"\n";
}

__DATA__
"V  c #767676 " /* "0.808" */,
"W  c #6F6F6F " /* "0.846" */,
"X  c #696969 " /* "0.885" */,
"Y  c #626262 " /* "0.923" */,
"Z  c #5C5C5C " /* "0.962" */,
"a  c #555555 " /* "1" */,
"b  c #4E4E4E " /* "1.04" */,
"c  c #484848 " /* "1.08" */,


>
> not work,
>
> mainly interest the
>
> V    0.808
> W   0.846
> .      .
> .      .
> .      .
>
> parts,
>
> Thanks for any suggestion,
>
> Best regards,
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>


-- 
Tim


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About