Re: strange regex problem with backslash and newline

2006-08-05 Thread John W. Krahn
Peter Daum wrote: > Hi, Hello, > when trying to process continuation lines in a file, I ran > into a weird phenomenon that I can't make any sense of: > > $s contains a line read from a file, that ends with a backslash > (+ the newline character), so > > $s='abc \ > '; > > $s =~ /^(.*)$/; print

Re: strange regex problem with backslash and newline

2006-08-05 Thread Peter Daum
Tom Phoenix wrote: > On 8/5/06, Peter Daum <[EMAIL PROTECTED]> wrote: >> $s =~ /^(.*[^\\])(\\)?$/; print "1: '$1', 2: '$2'"; > > Let's see what that pattern matches by annotating it: > > m{ >^ # start of string >( # memory 1 > .*# any ol' junk, including backslashes

Re: strange regex problem with backslash and newline

2006-08-05 Thread Tom Phoenix
On 8/5/06, Peter Daum <[EMAIL PROTECTED]> wrote: $s='abc \ '; $s =~ /^(.*[^\\])(\\)?$/; print "1: '$1', 2: '$2'"; Let's see what that pattern matches by annotating it: m{ ^ # start of string ( # memory 1 .*# any ol' junk, including backslashes [^\\] # any n

Re: strange regex problem with backslash and newline

2006-08-05 Thread D. Bolliger
Peter Daum am Samstag, 5. August 2006 18:45: > Hi, Hallo Peter > when trying to process continuation lines in a file, I ran > into a weird phenomenon that I can't make any sense of: > > $s contains a line read from a file, that ends with a backslash > (+ the newline character), so > > $s='abc \ >

strange regex problem with backslash and newline

2006-08-05 Thread Peter Daum
Hi, when trying to process continuation lines in a file, I ran into a weird phenomenon that I can't make any sense of: $s contains a line read from a file, that ends with a backslash (+ the newline character), so $s='abc \ '; $s =~ /^(.*)$/; print $1; # prints "abc \" as expected If the line