Ruby | Regexp encoding() function Last Updated : 17 Dec, 2019 Comments Improve Suggest changes Like Article Like Report Regexp#encoding() : encoding() is a Regexp class method which returns the encoding value of the regular expressions. Syntax: Regexp.encoding() Parameter: Regexp values Return: encoding value of the regular expressions Example #1 : Ruby # Ruby code for Regexp.encoding() method # declaring Regexp value reg_a = /a/ # declaring Regexp value reg_b = /geeks/ # declaring Regexp value reg_c = /a/ # encoding method puts "Regexp encoding form : #{reg_a.encoding}\n\n" puts "Regexp encoding form : #{reg_b.encoding}\n\n" puts "Regexp encoding form : #{reg_c.encoding}\n\n" Output : Regexp encoding form : US-ASCII Regexp encoding form : US-ASCII Regexp encoding form : US-ASCII Example #2 : Ruby # Ruby code for Regexp.encoding() method # declaring Regexp value reg_a = /geeks/ # declaring Regexp value reg_b = /problem/ # declaring Regexp value reg_c = /code/ # encoding method puts "Regexp encoding form : #{reg_a.encoding}\n\n" puts "Regexp encoding form : #{reg_b.encoding}\n\n" puts "Regexp encoding form : #{reg_c.encoding}\n\n" Output : Regexp encoding form : US-ASCII Regexp encoding form : US-ASCII Regexp encoding form : US-ASCII Comment More infoAdvertise with us Next Article Ruby | Regexp eql?() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Regexp-class Similar Reads Ruby | Regexp fixed_encoding?() function Regexp#fixed_encoding?() : fixed_encoding?() is a Regexp class method which checks whether the regular expression is applicable to a string with any ASCII compatible encoding. Syntax: Regexp.force_encoding?() Parameter: Regexp values Return: true - if the rxp is applicable to a string with any ASCII 1 min read Ruby | Regexp compile() function Regexp#compile() : compile() is a Regexp class method which completes a new Regular Expression. Syntax: Regexp.compile() Parameter: Regexp values Return: creates a new Regular Expression. Example #1 : Ruby # Ruby code for Regexp.compile() method # declaring Regexp value reg_a = Regexp.compile(/a/) # 1 min read Ruby | Regexp eql?() function Regexp#eql?() : eql?() is a Regexp class method which matches the character in two regular expression. Syntax: Regexp.eql?() Parameter: Regexp values Return: true - if two regular expressions matches string otherwise return false Example #1 : Ruby # Ruby code for Regexp.eql?() method # declaring Reg 1 min read Ruby | Regexp casefold?() function Regexp#casefold?() : casefold?() is a Regexp class method which returns the value of the case-insensitive flag of regular expressions. Syntax: Regexp.casefold?() Parameter: Regexp values Return: value of the case-insensitive flag of regular expressions Example #1 : Ruby # Ruby code for Regexp.casefo 1 min read Ruby | Regexp escape() function Regexp#escape() : escape() is a Regexp class method which returns a new string by escaping any characters that would have special meaning in a regular expression. Syntax: Regexp.escape() Parameter: Regexp values Return: a new string by escaping any characters that would have special meaning in a reg 1 min read Ruby | Regexp =~() function Regexp#=~() : =~() is a Regexp class method which matches a regular expression against a string. Syntax: Regexp.=~()Parameter: Regexp valuesReturn: true - if two regular expressions matches string otherwise return false Example #1 :  Ruby # Ruby code for Regexp.=~() method # declaring Regexp value 1 min read Like