Ruby | String end_with? Method Last Updated : 12 Dec, 2019 Comments Improve Suggest changes Like Article Like Report end_with? is a String class method in Ruby which is used to check if the specified string ends with one of the suffixes given or not. Syntax: str.end_with? Parameters: Here, str is the given string. Returns: true if it matches otherwise return false. Example 1: Ruby # Ruby program to demonstrate # the end_with? method # Taking a string and # using the method puts "Ruby".end_with?("by") puts "String".end_with?("ab") Output: true false Example 2: Ruby # Ruby program to demonstrate # the end_with? method # Taking a string and # using the method # returns true if one of # the +suffixes+ matches. puts "Sample".end_with?("ple", "sam") puts "Program".end_with?("gr", "pro") Output: true false Comment More infoAdvertise with us Next Article Ruby | String end_with? Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads Ruby | String eql? Method eql? is a String class method in Ruby which is used to check whether the strings are equal or not if they have the same length and content. Syntax: str.eql?(Other_str) Parameters: Here, str and other_str are the strings. Returns: True or false basis on the equality. Example 1: Ruby # Ruby program to 1 min read Ruby | String index Method index is a String class method in Ruby which is used to returns the index of the first occurrence of the given substring or pattern (regexp) in the given string. It specifies the position in the string to begin the search if the second parameter is present. It will return nil if not found. Syntax: s 1 min read Ruby | String hex Method hex is a String class method in Ruby which is used to treats the leading characters from the given string as a string of hexadecimal digits (with an optional sign and an optional 0x) and returns the corresponding number. Zero is returned on error. Syntax: str.hex Parameters: Here, str is the given s 1 min read Ruby | String length Method length is a String class method in Ruby which is used to find the character length of the given string. Syntax: str.length Parameters: Here, str is the string whose length is to be calculated Returns:It will return the character length of the str. Example 1: Ruby # Ruby program to demonstrate # the 1 min read Ruby | String =~ Method =~() is a String class method in Ruby which is used for matching purpose. If the given object is a Regexp, then this method will use it as a pattern to match against the given string. Syntax: str =~ obj Parameters: Here, str is the given string and obj is the object to be matched. Returns: The posit 1 min read Like