U
Une bévue
i'm experiencing with regexp and ruby and follo the page
<http://www.rubycentral.com/book/ref_c_regexp.html>
at "===" i've found an example :
a = "HELLO"
case a
when /^a-z*$/; print "Lower case\n"
when /^A-Z*$/; print "Upper case\n"
else; print "Mixed case\n"
end
saying it produces :
# => Upper case
i got :
Mixed case
why this discrapency, if any ???
is that due to the fact my script file is UTF-8 encoded ???
also with :
truc = 'toto'
rgx=Regexp.new('^toto$')
flag=(truc =~ rgx)? true : false
p "flag = #{flag}"
# => "flag = true"
flag=(truc === rgx) /// this one i don't understand the result
p "flag = #{flag}"
# => "flag = false"
flag=(truc == rgx)
p "flag = #{flag}"
# => "flag = false"
flag=(truc =~ rgx)
p "flag = #{flag}"
# => "flag = 0"
why, when aString = 'toto' and ARegexp = Regexp.new('^toto$')
the equality "===" returns false ???
<http://www.rubycentral.com/book/ref_c_regexp.html>
at "===" i've found an example :
a = "HELLO"
case a
when /^a-z*$/; print "Lower case\n"
when /^A-Z*$/; print "Upper case\n"
else; print "Mixed case\n"
end
saying it produces :
# => Upper case
i got :
Mixed case
why this discrapency, if any ???
is that due to the fact my script file is UTF-8 encoded ???
also with :
truc = 'toto'
rgx=Regexp.new('^toto$')
flag=(truc =~ rgx)? true : false
p "flag = #{flag}"
# => "flag = true"
flag=(truc === rgx) /// this one i don't understand the result
p "flag = #{flag}"
# => "flag = false"
flag=(truc == rgx)
p "flag = #{flag}"
# => "flag = false"
flag=(truc =~ rgx)
p "flag = #{flag}"
# => "flag = 0"
why, when aString = 'toto' and ARegexp = Regexp.new('^toto$')
the equality "===" returns false ???