Re: regex help
- From: ioneabu@xxxxxxxxx
- Date: 15 Apr 2005 14:54:30 -0700
Anno Siegel wrote:
> si <smcbutler@xxxxxxxxxxx> wrote in comp.lang.perl.misc:
> >
> > hi all, i had a regex question for the group:
> >
> > i'm trying to do parse a string 'a = 3 b = 4 c = 5 d = 6'
>
> [...]
>
> > any idea of how I can do this with regex?
>
> my $str = 'a = 3 b = 4 c = 5 d = 6';
> my %hash = $str =~ /(\w+)\s*=\s*(\d+)/g;
>
> Anno
not as good but different:
#!/usr/bin/perl
use strict;
use warnings;
my $str = 'a = 3 b = 4 c = 5 d = 6';
$str =~ s/[^a-z0-9]+/ /g;
my %hash = split / /, $str;
print "$_ = $hash{$_}\n" for keys %hash;
wana
.
- Follow-Ups:
- Re: regex help
- From: John W. Krahn
- Re: regex help
- References:
- regex help
- From: si
- Re: regex help
- From: Anno Siegel
- regex help
- Prev by Date: Re: Net::FTP problem
- Next by Date: Re: Net::FTP problem
- Previous by thread: Re: regex help
- Next by thread: Re: regex help
- Index(es):
Relevant Pages
|