Ruby | Regexp quote() function Last Updated : 17 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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 code for Regexp.quote() method # declaring Regexp value reg_a = Regexp.quote('/a/') # declaring Regexp value reg_c = Regexp.quote('\*?{}.') # quote method puts "Regexp quote form : #{reg_a}\n\n" puts "Regexp quote form : #{reg_c}\n\n" Output : Regexp quote form : /a/ Regexp quote form : \\\*\?\{\}\. Example #2 : Ruby # Ruby code for Regexp.quote() method # declaring Regexp value reg_a = Regexp.quote('/geeks/') # declaring Regexp value reg_b = Regexp.quote('/(?<geeks>.)(?<for>.)(?<geeks>.)/') # declaring Regexp value reg_c = Regexp.quote('\*?????{}.') # quote method puts "Regexp quote form : #{reg_a}\n\n" puts "Regexp quote form : #{reg_b}\n\n" puts "Regexp quote form : #{reg_c}\n\n" Output : Regexp quote form : /geeks/ Regexp quote form : /\(\?\.\)\(\?\.\)\(\?\.\)/ Regexp quote form : \\\*\?\?\?\?\?\{\}\. Comment More infoAdvertise with us Next Article Ruby | Regexp quote() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Regexp-class Similar Reads 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 =~() 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 match() function Regexp#match() : force_encoding?() is a Regexp class method which matches the regular expression with the string and specifies the position in the string to begin the search. Syntax: Regexp.match() Parameter: Regexp values Return: regular expression with the string after matching it. Example #1 : Ru 1 min read Like