Ruby | Regexp to_s() function Last Updated : 17 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Regexp#to_s() : to_s() is a Regexp class method which returns the string containing the regular expression with the same semantics. Syntax: Regexp.to_s() Parameter: Regexp values Return: string containing the regular expression with the same semantics. Example #1 : Ruby # Ruby code for Regexp.to_s() method # declaring Regexp value reg_a = /a/ # declaring Regexp value reg_b = /\xa1\xa2/e # to_s method puts "Regexp to_s form : #{reg_a.to_s}\n\n" puts "Regexp to_s form : #{reg_b.to_s}\n\n" Output : Regexp to_s form : (?-mix:a) Regexp to_s form : (?-mix:\xa1\xa2) Example #2 : Ruby # Ruby code for Regexp.to_s() method # declaring Regexp value reg_a = /geeks/ix # declaring Regexp value reg_b = /(.)(.)/ # to_s method puts "Regexp to_s form : #{reg_a.to_s}\n\n" puts "Regexp to_s form : #{reg_b.to_s}\n\n" Output : Regexp to_s form : (?ix-m:geeks) Regexp to_s form : (?-mix:(.)(.)) Comment More infoAdvertise with us Next Article Ruby | Regexp ===() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Regexp-class Similar Reads Ruby | Range to_s() function The to_s() is an inbuilt method in Ruby returns a string containing the given range. Syntax: range1.to_s() Parameters: The function accepts no parameter. Return Value: It returns a string containing the range. Example 1: Ruby # Ruby program for to_s() # method in Range # Initialize range range1 = (0 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 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 Ruby | Regexp ===() function Regexp#===() : ===() is a Regexp class method which compares the equality of two regular expressions. Syntax: Regexp.===() Parameter: Regexp values Return: true - if two regular expressions has equality otherwise return false Example #1 : Ruby # Ruby code for Regexp.===() method # declaring Regexp v 1 min read Ruby | Regexp source() function Regexp#source() : source() is a Regexp class method which returns the original string of the pattern. Syntax: Regexp.source() Parameter: Regexp values Return: original string of the pattern. Example #1 : Ruby # Ruby code for Regexp.source() method # declaring Regexp value reg_a = /a/ # declaring Reg 1 min read Ruby | Matrix to_s() function The to_s() is an inbuilt method in Ruby returns a string containing the matrix as the object. Syntax: mat1.to_s() Parameters: The function needs the matrix whose string object is to be returned. Return Value: It returns a string or self. Example 1: Ruby # Ruby program for to_s() method in Matrix # I 1 min read Like