Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: pick a word contaning reg-ex

by Lotus1 (Chaplain)
on Dec 04, 2012 at 15:19 UTC ( #1007106=note: print w/ replies, xml ) Need Help??


in reply to Re^2: pick a word contaning reg-ex
in thread pick a word contaning reg-ex

I just tried the code above and it only prints the first word (update: on each line) that contains an exclamation point.

#!/perl use warnings; use strict; while(<DATA>){ #print map {"$_\n"} grep{/!/} split; /(\w*!\w*)/g && print "$1\n"; } __DATA__ Mary had a little lamb! , whose fleece! was white! as snow. And everywhere! that Mary went, the lamb was sure! to go. oops!eedaisy

Produces this:

lamb! fleece! everywhere! sure! oops!eedaisy


Comment on Re^3: pick a word contaning reg-ex
Select or Download Code
Re^4: pick a word contaning reg-ex
by space_monk (Chaplain) on Dec 04, 2012 at 16:59 UTC
    Oops - try
    while (/(\w*!\w*)/g) { print "$1\n"; }
    A Monk aims to give answers to those who have none, and to learn from those who know more.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2015-07-05 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls