Tom Allison wrote:
> How do I pull all the words from a line between the two words 'from' and
> 'by' when I have NO IDEA what's in there, but I know they are all in one
> line.
> 
> To make it more difficult.  'by' is optional...
> 
> Like this:
> 
> from......by......
> or
> from......
> 
> I want all the stuff inside.
> 
> Initially I'm thinking
> /from (.+?) (?:by (.+?))?/
> 
> Anything better?

$ perl -le'
for ( "abc from to the word by and the end", "abc from to the end" ) {
    print $1 if /from(.*?(?=by)|.*)/;
    }
'
 to the word
 to the end




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to