Ruby | Regexp options() function Last Updated : 17 Dec, 2019 Comments Improve Suggest changes Like Article Like Report Regexp#options() : options() is a Regexp class method which returns the set of bits corresponding to the options used when creating the Regular Expression. Syntax: Regexp.options() Parameter: Regexp values Return: set of bits corresponding to the options used when creating the Regular Expression. Example #1 : Ruby # Ruby code for Regexp.options() method # declaring Regexp value reg_a = /a/ # declaring Regexp value reg_b = /\xa1\xa2/e # declaring Regexp value reg_c =/(?<go>.)(?<for>.)(?<it>.)/ # options method puts "Regexp options form : #{reg_a.options}\n\n" puts "Regexp options form : #{reg_b.options}\n\n" puts "Regexp options form : #{reg_c.options}\n\n" Output : Regexp options form : 0 Regexp options form : 16 Regexp options form : 0 Example #2 : Ruby # Ruby code for Regexp.options() method # declaring Regexp value reg_a = /geeks/ix # declaring Regexp value reg_b = /(?<hi>.)(?<there>.)e/ # declaring Regexp value reg_c = /(?<i>.)(?<can>.)(?<code>.)/ # options method puts "Regexp options form : #{reg_a.options}\n\n" puts "Regexp options form : #{reg_b.options}\n\n" puts "Regexp options form : #{reg_c.options}\n\n" Output : Regexp options form : 3 Regexp options form : 0 Regexp options form : 0 Comment More infoAdvertise with us Next Article Ruby | Regexp options() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Regexp-class Similar Reads Ruby | Regexp inspect() function Regexp#inspect() is a Regexp class method which produces a formatted string-version of regular expression. Syntax: Regexp.inspect()Parameter: Regexp valuesReturn: a formatted string-version of regular expression Example #1 :  Ruby # Ruby code for Regexp.inspect() method # declaring Regexp value re 1 min read Ruby | Regexp quote() function Regexp#quote() : quote() is a Regexp class method which escapes any characters that would have special meaning in a regular expression. Syntax: Regexp.quote() Parameter: Regexp values Return: escapes any characters that would have special meaning in a regular expression. Example #1 : Ruby # Ruby cod 1 min read Ruby | Regexp new() function Regexp#new() : new() is a Regexp class method which returns a new regular expression pattern. Syntax: Regexp.new() Parameter: Regexp values Return: a new regular expression pattern Example #1 : Ruby # Ruby code for Regexp.new() method # declaring Regexp value reg_a = Regexp.new('/a/') # declaring Re 1 min read Ruby | Regexp names() function Regexp#names() : names() is a Regexp class method which produces a formatted string-version of regular expression. Syntax: Regexp.names()Parameter: Regexp valuesReturn: a formatted string-version of regular expression Example #1 :  Ruby # Ruby code for Regexp.names() method # declaring Regexp valu 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