in reply to Trying to find all items in between quotation and speech marks
#!/usr/bin/perl -w use strict; my $text =""; while (<DATA>) { s/\n/ /; #not graceful way of \n $text = $text.$_; #not either, but not main point... } #main point is to use match global (/g) #think about /m and /s options also #this is just an example of an idea.... # my @quotes = $text =~ m/["'](.*?)["']/g; print join("\n",@quotes),"\n"; __DATA__ "Mary and a little lamb", she said. She thought 'Hang on a tick'. this 'is a line spanning quote' and course not! I really do not know about the really stange things, "But this is another line span quote" Nobody loves me "Mary and a large lamb" this is just nonsense the PM said 'something' __END__ OUTPUT: Mary and a little lamb Hang on a tick is a line spanning quote But this is another line span quote Mary and a large lamb something
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trying to find all items in between quotation and speech marks
by AnomalousMonk (Archbishop) on Jan 24, 2009 at 19:25 UTC | |
by Marshall (Canon) on Jan 26, 2009 at 00:52 UTC |