You're regex (\w\S*) is matching them all but all within the regex loop, so
only the last is captured. You'll either have to do something fancy with
the zero length execution {?{ code here.. something like that }} or change
your approach to take it a chunk at a time.

On Thu, Oct 25, 2012 at 3:57 PM, Kripa Sundar <[email protected]> wrote:

> Folks,
>
> I need help to reset my brain, w.r.t. an apparently-straightforward regex.
> I am sure I am missing something obvious here.
>
> I keep thinking that the regex below ought to get me all the words on a
> line
> except the backslash.  Instead I am only getting the final word.
>
> (In my code, I threw out the regex, and resorted to split().  But my mental
> blind spot on this regex is bothering me.)
>
> > % cat > input.txt
> > a b c \
> > d e
> > %
> > % perl -lne 'print for m{ ^ (?: \s* (\w\S*) )+ \s* \\? $ }xg' !$
> > c
> > e
> > %
>
> peace,          || Just the facts, ma'am:
> --{kr.pA}       || http://www.washingtonpost.com/blogs/fact-checker/
> --
> Yoga: origami for people.
>
> _______________________________________________
> Boston-pm mailing list
> [email protected]
> http://mail.pm.org/mailman/listinfo/boston-pm
>

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to