Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Repeating a capture group pattern within a pattern

by Anonymous Monk
on Jul 18, 2024 at 05:46 UTC ( [id://11160667]=note: print w/replies, xml ) Need Help??


in reply to Repeating a capture group pattern within a pattern

You're over thinking it.
my $x = "0.01 NaN 2.30 4.44";
Match the form rather than the content of the data:
my $r1 = qr/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/;
Or ditch the pattern and split, as others suggest:
my ($d, $e, $f, $g) = split /\s+/, $x;
  • Comment on Re: Repeating a capture group pattern within a pattern

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-09-09 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.