develooper Front page | perl.beginners | Postings from May 2007

regex question

Thread Next
From:
Tom Allison
Date:
May 14, 2007 18:44
Subject:
regex question
Message ID:
46491054.8050905@tacocat.net
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?

I can negate a character  with [^b] to mean not-'b'
but can I negate a word?

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About