Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Parse for a list in a long string

by Anonymous Monk
on Jun 02, 2015 at 19:35 UTC ( [id://1128843]=note: print w/replies, xml ) Need Help??


in reply to Parse for a list in a long string

It's really a double loop.

#!/usr/bin/perl # http://perlmonks.org/?node_id=1128809 use strict; use warnings; while(<DATA>) { my @items; s/\s+/ /g; # simplify push @items, $1 =~ /, *(\w+)/g while /\btest \w+((?:, *\w+(?: is \w+ +)?)+)/g; @items and print "FOUND: @items\n"; } __DATA__ this line has nothing, nothing, nothing... 1 , 2, 3, 4 is four, 5, 6 test 00,11 is one,22, 33 is three,44,55 is + the best, and this is not a test 111, 222, 333 as random words to + finish this should be a test, but nothing must be returned 4444, 7777, 9999 i +s garbage

Log In?
Username:
Password:

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

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

    No recent polls found