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 match() 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 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 | 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 | 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