in reply to Re^2: Question on File position, pulling words
in thread Question on File position, pulling words

Don't overlook my .*. As you can learn in perlretut,

the first quantifier .* grabs as much of the string as possible while still having the regexp match.

My submission said

/.* # Read as far as possible before \s # matching whitespace, (\S+) # capturing a word, \s+ # matching more whitespace, (\S+) # and finally capturing the last word. /x

Replies are listed 'Best First'.
Re^4: Question on File position, pulling words
by hipowls (Curate) on Mar 04, 2008 at 07:42 UTC

    True and faster, at least on long strings (I had hoped to riposté by pointing out mine was faster but that is true only on short strings ;-)