Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Help with pattern matching quantifiers

by rsFalse (Chaplain)
on Oct 28, 2016 at 09:47 UTC ( [id://1174881]=note: print w/replies, xml ) Need Help??


in reply to Re: Help with pattern matching quantifiers
in thread Help with pattern matching quantifiers

#!/usr/bin/perl use strict; use warnings; while(<DATA>) { my @values = map { split /\d\K\b/ } split ' '; print "@values\n"; } __DATA__ -8-18 -9-10 -8 -7 -9-10 -9 -6 -5 -8 12 -7-10 -8 -8 -8 -8 -6 -3 2 2 -2 -8 1 -2 -5 -1 -4 -6 6 -4 -6 -5 -1 0 -8 -6 -6 3 -6 -3 -6 -2 -5 -5 -5 -4 4 -3 -2 -2 -3 -5 1 3 -7 -4 3 1 -6 -5 -6 4 -5 -6 -5 -6 3 1 -5 -3 -2 -5 -1 3 -4 -3 4 2 -8 -6 -7 -8 -8 -8 7 -8 -9 -9 -7 -8 -6 -8 -4 -7 -9 -9 -8
Or split by any num of spaces, and additionally split with zero-length matches (find decimal, don't grab previous, find word bound. (e.g.: '-8-18' -> ('-8', '-18')).

Look, that your regex ([\d\-]+) will take both numbers '-8-18' into $1.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found