[Boston.pm] Perl regex question

2012-10-25 Thread Kripa Sundar
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

Re: [Boston.pm] Perl regex question

2012-10-25 Thread Jordan Adler
Kripa, Well, the problem with your regex is the binding on the end and beginning of each line. Here's a simplified version of your regex, that produces identical results: hf:~$ perl -lne 'print for m{^(\w\s*?)+\s*?\\?$}g' input.txt c e Watch what happens when we remove the match for end of

Re: [Boston.pm] Perl regex question

2012-10-25 Thread Jordan Adler
I should clarify: it only captures the one match within the boundaries of the regex. Your regex matches the entire line, thus it only captures the one match within the boundaries of the entire line. -- Thanks, Jordan M. Adler ___ Boston-pm mailing

Re: [Boston.pm] Perl regex question

2012-10-25 Thread Anthony Ball
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

Re: [Boston.pm] Perl regex question

2012-10-25 Thread Duane Bronson
m// returns an array of ($1,$2,$3...), but your word (\w\S*) is always $1 even though it's hit multiple times. You're only getting the last hit. the /g is useless because of the ^ and $ It's hard to tell exactly what you want. Are you saying strip the trailing \ and then grab the words that

Re: [Boston.pm] Perl regex question

2012-10-25 Thread Kripa Sundar
Thanks to all who replied so promptly. Duane's explanation captured it best for me. From: Duane Bronson Subject: Re: [Boston.pm] Perl regex question Date: Thu, Oct 25, 2012 at 06:31:01PM -0400 m// returns an array of ($1,$2,$3...), but your word (\w\S*) is always $1 even though it's hit