Ruby | Regexp inspect() function Last Updated : 17 May, 2021 Comments Improve Suggest changes Like Article Like Report 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 reg_a = /a/ # declaring Regexp value reg_b = /geeks/ # declaring Regexp value reg_c = /a/ # inspect method puts "Regexp inspect form : #{reg_a.inspect}\n\n" puts "Regexp inspect form : #{reg_b.inspect}\n\n" puts "Regexp inspect form : #{reg_c.inspect}\n\n" Output : Regexp inspect form : /a/ Regexp inspect form : /geeks/ Regexp inspect form : /a/ Example #2 : Ruby # Ruby code for Regexp.inspect() method # declaring Regexp value reg_a = /geeks/ # declaring Regexp value reg_b = /problem/ # declaring Regexp value reg_c = /code/ # inspect method puts "Regexp inspect form : #{reg_a.inspect}\n\n" puts "Regexp inspect form : #{reg_b.inspect}\n\n" puts "Regexp inspect form : #{reg_c.inspect}\n\n" Output : Regexp inspect form : /geeks/ Regexp inspect form : /problem/ Regexp inspect form : /code/ Comment More infoAdvertise with us Next Article Ruby | Regexp inspect() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Regexp-class Similar Reads Ruby | Range inspect() function The inspect() is an inbuilt method in Ruby returns the range object in a printable form Syntax: range1.inspect() Parameters: The function accepts no parameter Return Value: It returns the range object in a printable form Example 1: Ruby # Ruby program for inspect() # method in Range # Initialize ran 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 options() function 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. Ex 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 compares two regular expressions. Syntax: Regexp.==() Parameter: Regexp values Return: true - if two regular expressions are equal otherwise return false Example #1 : Ruby # Ruby code for Regexp.==() method # declaring Regexp value reg_a = /a/ # decl 1 min read Like