From: Glen Holcomb Date: 2011-08-11T20:52:26+09:00 Subject: Re: Odd regexp behavior --00163631081b27369b04aa396d75 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Thu, Aug 11, 2011 at 12:41 AM, 7stud -- wrote: > Also, > > > str =3D "hello\nhello" > > str.scan(/^hell/) {|match| p match} > puts "-" * 20 > str.scan(/\Ahell/) {|match| p match} > > --output:-- > "hell" > "hell" > -------------------- > "hell" > > -- > Posted via http://www.ruby-forum.com/. > > Hmmm... maybe I should have posted from the beginning rather than where I had gotten to in my attempt to solve my problem. I am tyring to parse log files and am pulling out encapsulated fields so that I can split the line in a sane way. I have the following regex which = I am using to do that: /\s(".*?")(\s|$)/ Now as to why I'm looking for the \s before and the \s or $ after. It turn= s out that some of the user agent strings are in a format like "\"Custom Agent\"=3D\"Mozilla ...\""\n I had been using the regex Ryan suggested earlier until I discovered the nested quotes. The expression above works for quoted strings surrounded by spaces but not the last one on the line. I've tried changing $ to \n and that didn't make any difference. Here is the exact code I'm using: x =3D "encapsulatorhere" stash =3D {} gen_encap_matches.each do |encapex| line.gsub!(encapex) do |match| x.next! stash[x] =3D $1 @job.log_format.separator + x + @job.log_format.separator end end gen_encap_matches just creates the regexes from a list of encapsulation characters. I'm at a complete loss as to why it won't grab the last quoted string in th= e line. --=20 "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can=92t hear a word you=92re saying." -Greg Graffin (Bad Religion) --00163631081b27369b04aa396d75--