I started learning regular expressions in ruby. I had one problem with this. The problem is that the regex below does not work as expected.
/^[\s]*$/ -- This will match only if the input contains white spaces or the input contains empty.
For instance,
str = "
abc
"
if str =~ /^[\s]*$/
puts "Condition is true"
else
puts "Condition is false"
end
My expectation is that this condition will be false. But that is becoming true. I do not know why?
In sed or grep, it will work as expected. But why it does not work in ruby.
source
share