Hello,
Why does the following:
s = "aaa aaa\n\n\nbbb bbb"
puts(s =~ /^\s+$/)
produce: 8 (instead of nil) ?
(If I put in only 2 newlines, it's fine).
This is in several 1.8.2 rpms (caliban, fc3).
Cheers,
Han Holl
Hello,
Why does the following:
s = "aaa aaa\n\n\nbbb bbb"
puts(s =~ /^\s+$/)
produce: 8 (instead of nil) ?
(If I put in only 2 newlines, it's fine).
This is in several 1.8.2 rpms (caliban, fc3).
Cheers,
Han Holl
Hello,
Why does the following:
s = "aaa aaa\n\n\nbbb bbb"
puts(s =~ /^\s+$/)produce: 8 (instead of nil) ?
^ means the beginning a line (right after \n)
$ means the end a line (right before \n)
\s+ manes one or more whitespace characters (the \n in the middle)
Does that clarify the match?
(If I put in only 2 newlines, it's fine).
You can't satisfy all three conditions with only two \n characters.
Hope that helps.
James Edward Gray II
On Apr 6, 2005, at 9:44 AM, Han Holl wrote:
Han Holl wrote:
Why does the following:
s = "aaa aaa\n\n\nbbb bbb"
puts(s =~ /^\s+$/)produce: 8 (instead of nil) ?
Maybe you would rather use \A and \Z instead of ^ and $:
puts(s =~ /\A\s+\Z/) => nil
--
Glenn Parker | glenn.parker-AT-comcast.net | <http://www.tetrafoil.com/>