Ruby | Regexp hash() function Last Updated : 17 Dec, 2019 Comments Improve Suggest changes Like Article Like Report Regexp#force_encoding?() : force_encoding?() is a Regexp class method which returns the hash based on the text and options of this regular expression. Syntax: Regexp.hash() Parameter: Regexp values Return: the hash based on the text and options of this regular expression. Example #1 : Ruby # Ruby code for Regexp.hash() method # declaring Regexp value reg_a = /a/ # declaring Regexp value reg_b = /geeks/ # declaring Regexp value reg_c = /a/ # hash method puts "Regexp hash form : #{reg_a.hash}\n\n" puts "Regexp hash form : #{reg_b.hash}\n\n" puts "Regexp hash form : #{reg_c.hash}\n\n" Output : Regexp hash form : -1704400854280844509 Regexp hash form : -3140932202593119845 Regexp hash form : -1704400854280844509 Example #2 : Ruby # Ruby code for Regexp.hash() method # declaring Regexp value reg_a = /geeks/ # declaring Regexp value reg_b = /problem/ # declaring Regexp value reg_c = /code/ # hash method puts "Regexp hash form : #{reg_a.hash}\n\n" puts "Regexp hash form : #{reg_b.hash}\n\n" puts "Regexp hash form : #{reg_c.hash}\n\n" Output : Regexp hash form : -429624664738525607 Regexp hash form : -2782281071524532422 Regexp hash form : -3545766771755419715 Comment More infoAdvertise with us Next Article Ruby | Regexp hash() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Regexp-class Similar Reads 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 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 | Range hash() function The hash() is an inbuilt method in Ruby returns a hash-code for the given range. The hash-value will vary for every execution. Syntax: range1.hash() Parameters: The function accepts no parameter. Return Value: It returns a hash-code for the given range. Example 1: Ruby # Ruby program for hash() # me 1 min read Ruby | Hash merge function Hash#merge() is a Hash class method which combines two hash arrays and their content. Syntax: Hash.merge() Parameter: Hash values Return: combine two hash arrays Example #1 : Ruby # Ruby code for Hash.merge() method # declaring Hash value a = {a:100, b:200} # declaring Hash value b = {a:100, c:300, 2 min read Ruby | Hash merge! function Hash#merge!() : merge!() is a Hash class method which can add the content the given hash array to the other. Entries with duplicate keys are overwritten with the values from each other_hash successively if no block is given. Syntax: Hash.merge!() Parameter: Hash values Return: add the content the gi 2 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 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 ==() 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 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 | Hash keep_if() function Hash#keep_if() is a Hash class method which only keeps those key value pair that follows the block condition. Syntax: Hash.keep_if() Parameter: Hash values block - condition Return: key value pair that follows the block condition Example #1 : Ruby # Ruby code for Hash.keep_if() method # declaring Ha 2 min read Like