📜  红宝石 |正则表达式 fixed_encoding?()函数

📅  最后修改于: 2022-05-13 01:54:33.814000             🧑  作者: Mango

红宝石 |正则表达式 fixed_encoding?()函数

Regexp#fixed_encoding?() : fixed_encoding?()是一个 Regexp 类方法,用于检查正则表达式是否适用于具有任何 ASCII 兼容编码的字符串。

示例 #1:

# Ruby code for Regexp.fixed_encoding?() method
  
# declaring Regexp value
reg_a = /a/
  
# declaring Regexp value
reg_b = /geeks/
  
# declaring Regexp value
reg_c = /a/
  
  
#  fixed_encoding? method
puts "Regexp fixed_encoding? form : #{reg_a.fixed_encoding?}\n\n"
  
puts "Regexp fixed_encoding? form : #{reg_b.fixed_encoding?}\n\n"
  
puts "Regexp fixed_encoding? form : #{reg_c.fixed_encoding?}\n\n"

输出 :

Regexp fixed_encoding? form : false

Regexp fixed_encoding? form : false

Regexp fixed_encoding? form : false

示例 #2:

# Ruby code for Regexp.fixed_encoding?() method
  
# declaring Regexp value
reg_a = /geeks/
  
# declaring Regexp value
reg_b = /problem/
  
# declaring Regexp value
reg_c = /code/
  
  
#  fixed_encoding? method
puts "Regexp fixed_encoding? form : #{reg_a.fixed_encoding?}\n\n"
  
puts "Regexp fixed_encoding? form : #{reg_b.fixed_encoding?}\n\n"
  
puts "Regexp fixed_encoding? form : #{reg_c.fixed_encoding?}\n\n"

输出 :

Regexp fixed_encoding? form : false

Regexp fixed_encoding? form : false

Regexp fixed_encoding? form : false