From: 7stud -- Date: 2011-08-11T15:35:24+09:00 Subject: Re: Odd regexp behavior 7stud -- wrote in post #1016116: > 7stud -- wrote in post #1016113: >> >> It's pretty simple: $ matches before a newline--not the end of a string. >> > > Actually, $ matches after a newline. > Whoops. puts "hello\nworld" p "hello\nworld" --output:-- hello world "hello\nworld" def show_match(str,re) if str =~ re "#{$`}<<#{$&}>>#{$'}" else "no match" end end p show_match("hello\nhello", /llo$/) p show_match("hello\nhello", /llo\z/x) --output:-- "he<>\nhello" "hello\nhe<>" -- Posted via http://www.ruby-forum.com/.