Re: RegEx challenge - doesn't work
From: l v (lv_at_aol.com)
Date: 11/16/04
- Next message: DGP: "First Perl Program"
- Previous message: A. Sinan Unur: "Re: RegEx challenge - doesn't work"
- In reply to: John R: "Re: RegEx challenge - doesn't work"
- Next in thread: Tad McClellan: "Re: RegEx challenge - doesn't work"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 16 Nov 2004 15:04:22 -0600
"John R" <google@servangle.net> wrote in message
news:100a40e5.0411161204.3a13a9a9@posting.google.com...
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:<Xns95A2D6215D1Casu1cornelledu@132.236.56.8>...
> > while(<DATA>) {
> > if( /^dsr:(".+"); height:(\d+); width:(\d+); client:(".+")\s*$/ ) {
> > push @data, {
> > dsr => $1,
> > height => $2,
> > width => $3,
> > client => $4,
> > };
> > }
> > }
>
> Thanks for the effort, but this will not work either. Your regex is
> pattern matching the specific words "dsr" "height" etc... Maybe I
> should have mentioned this earlier, the name/value pairs cannot be
> predicted. The expected format is:
> name:value; name:value; name:"value blah"; name:"valu;e"
>
> > Yeah whatever ... An almost identical question was posted and answered
> > withing the last couple of days. Doesn't anyone lurk and read the FAQ
any
> > more?
>
> Give me some more credit here. I read the FAQ. This is a unique
> situation.
>
> > What do you mean "resulting in two arrays"?
>
> RegEx option /m like /(\w+):?([^;]+)?;\s?/m for multiple matches
> you'll get an array foreach grouping () eachtime the pattern is
> repeatedly matched.
>
> Does anyone understand my question?
>
> <snip>
try splitting vs regex
@groups = split(/; /, $line);
for my $group (@groups) {
my ($key, $value) = split(/:/, $group);
print "$key -> $value\n";
}
Len
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
- Next message: DGP: "First Perl Program"
- Previous message: A. Sinan Unur: "Re: RegEx challenge - doesn't work"
- In reply to: John R: "Re: RegEx challenge - doesn't work"
- Next in thread: Tad McClellan: "Re: RegEx challenge - doesn't work"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|