Regexp#casefold?():casefold?()是一個Regexp類方法,它返回正則表達式的不區分大小寫標誌的值。
用法:Regexp.casefold?()
參數:正則表達式值
返回:正則表達式的不區分大小寫標誌的值
範例1:
# Ruby code for Regexp.casefold?() method
# declaring Regexp value
reg_a = /a/
# declaring Regexp value
reg_b = /geeks/i
# declaring Regexp value
reg_c = /a/
# casefold? method
puts "Regexp casefold? form:#{reg_a.casefold?}\n\n"
puts "Regexp casefold? form:#{reg_b.casefold?}\n\n"
puts "Regexp casefold? form:#{reg_c.casefold?}\n\n"
輸出:
Regexp casefold? form:false Regexp casefold? form:true Regexp casefold? form:false
範例2:
# Ruby code for Regexp.casefold?() method
# declaring Regexp value
reg_a = /geeks/
# declaring Regexp value
reg_b = /problem/
# declaring Regexp value
reg_c = /code/i
# casefold? method
puts "Regexp casefold? form:#{reg_a.casefold?}\n\n"
puts "Regexp casefold? form:#{reg_b.casefold?}\n\n"
puts "Regexp casefold? form:#{reg_c.casefold?}\n\n"
輸出:
Regexp casefold? form:false Regexp casefold? form:false Regexp casefold? form:true
相關用法
- Ruby Regexp eql?()用法及代碼示例
- Ruby Regexp new()用法及代碼示例
- Scala Regexp ===()用法及代碼示例
- Scala Regexp ==()用法及代碼示例
- Scala Regexp =~()用法及代碼示例
- Ruby Regexp named_captures()用法及代碼示例
- Ruby Regexp options()用法及代碼示例
- Ruby Regexp escape()用法及代碼示例
- Ruby Regexp inspect()用法及代碼示例
- Ruby Regexp hash()用法及代碼示例
- Ruby Regexp match()用法及代碼示例
- Ruby Regexp names()用法及代碼示例
- Ruby Regexp quote()用法及代碼示例
- Ruby Regexp source()用法及代碼示例
- Ruby Regexp to_s()用法及代碼示例
注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | Regexp casefold?() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。