Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regular expression double grouping negation headache

by Ay_Bee (Monk)
on Jun 30, 2002 at 15:58 UTC ( [id://178382]=note: print w/replies, xml ) Need Help??


in reply to Regular expression double grouping negation headache

I normally hesitate to post my thoughts in such learned company, but here goes.
under Win32 perl test.pl QUICK=BROWN\ FOX JUMPED=OVER\ THE\ LAZY DOG produced an @ARGV of $ARGV[0] = 'QUICK=BROWN\\'; $ARGV[1] = 'FOX'; $ARGV[2] = 'JUMPED=OVER\\'; $ARGV[3] = 'THE\\'; $ARGV[4] = 'LAZY'; $ARGV[5] = 'DOG'; So to achieve the result required I tried my $line = join ' ', @ARGV; $line =~ s/\s(?=\S+=)/\t/g; @pairs = split(/\t/, $line); %defaults = map {/([^=]+) # everything up to the = sign into + $1 = # the = sign ((\S+\\\s)+ # all words followed by "\ " \S+) # word after the last "\ " /x?($1=>$2):()} @pairs; for ( keys %defaults) { print $_,"=",$defaults{$_},"\n"; }; which produced QUICK=BROWN\ FOX JUMPED=OVER\ THE\ LAZY
Ay_Bee
-_-_-_-_-_-_-_-_-_-_-_- My memory concerns me - but I forget why !!!

Log In?
Username:
Password:

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

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

    No recent polls found