Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
laziness, impatience, and hubris
 
PerlMonks  

Re^3: How to improve regex for parsing equals delimited data

by sauoq (Abbot)
on May 11, 2012 at 03:51 UTC ( #969897=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to improve regex for parsing equals delimited data
in thread How to improve regex for parsing equals delimited data

His fields can have spaces: "SOH: 169879251".

-sauoq
"My two cents aren't worth a dime.";


Comment on Re^3: How to improve regex for parsing equals delimited data
Download Code
Re^4: How to improve regex for parsing equals delimited data
by jwkrahn (Prior) on May 11, 2012 at 05:43 UTC
    my @fld = map /=s*(.+)/, /\b +\b/g; print join( ',', @fld ), "\n";

    Update: Thanks Lotus1, it should be:

    my @fld = map /=\s*(.+)/, split /\b +\b/; print join( ',', @fld ), "\n";

      I like the idea of using map this way but I couldn't get this to work. It just prints blank lines. I tried putting a '\' in front of the s* but that didn't help. It looks to me like the /\b +\b/g won't return anything without parenthesis. I'm not sure how to make this work.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2013-06-19 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many continents have you visited?









    Results (654 votes), past polls