Ruby | String delete! Method Last Updated : 13 Dec, 2019 Comments Improve Suggest changes Like Article Like Report delete! is a String class method in Ruby which is used to perform a delete operation, returning the given string, or nil if the given string was not modified. Syntax: str.delete!(parameter_list) Parameters: Here, str is the given string and parameter_list are the specified characters. Returns: nil if the string not modified. Example 1: Ruby # Ruby program to demonstrate # the delete! method # Taking a string and # using the method str = "String Counting" puts str.delete! "ing" Output: Str Cout Example 2: Ruby # Ruby program to demonstrate # the delete! method # Taking a string and # using the method str = "String Counting" puts str.delete! "ing", "^n" str2 = "Ruby Method" puts str2.delete! "ZXC" Output: Strn Countn Comment More infoAdvertise with us Next Article Ruby | String delete! Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads Ruby | String delete() Method delete is a String class method in Ruby which is used to return a copy of the given string with all characters in the intersection of its arguments deleted. Syntax: str.delete(parameter_list) Parameters: Here, str is the given string and parameter_list are the specified characters. Returns: A new co 1 min read 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 delete_prefix! Method delete_prefix! is a String class method in Ruby which is used to return a a copy of the given string with leading prefix deleted or nil if no change was made. Syntax: str.delete_prefix Parameters: Here, str is the given string. Returns: A copy of the given string with leading prefix deleted or nil i 1 min read Ruby | String delete_suffix! Method delete_suffix! is a String class method in Ruby which is used to return a copy of the given string with trailing suffix deleted or nil if no change was made. Syntax:str.delete_suffix! Parameters: Here, str is the given string. Returns: A copy of the given string with trailing suffix deleted or nil i 1 min read Ruby | String delete_prefix Method delete_prefix is a String class method in Ruby which is used to return a a copy of the given string with leading prefix deleted. Syntax: str.delete_prefix Parameters: Here, str is the given string. Returns: A copy of the given string with leading prefix deleted. Example 1: Ruby # Ruby program to dem 1 min read Ruby | String delete_suffix Method delete_suffix is a String class method in Ruby which is used to return a a copy of the given string with trailing suffix deleted. Syntax: str.delete_suffix Parameters: Here, str is the given string. Returns: A copy of the given string with trailing suffix deleted. Example 1:Â Ruby # Ruby program to 1 min read Ruby| String Clear Method clear is a String class method in Ruby which is used to make the string empty. Syntax: str.clear Parameters: Here, str is the given string. Return : An empty string. Example 1: Ruby # Ruby program to demonstrate # the clear method # Taking a string and # using the method puts "String".clea 1 min read Ruby | String <=> Method <=>() is a String class method in Ruby which is used for comparisons of the strings. This method returns -1, 0, +1, or nil depending on whether the specified string is less than, equal to, or greater than other_string. Syntax: str other_string Parameters: Here, str and other_string are the str 1 min read Ruby | String << Method <<() is a String class method in Ruby which is used to append the given object to the string. If the object is an integer, then by default it is considered a codepoint and converted to a character before being appended. Syntax: str << "object" Parameters: Here, str is the speci 1 min read Ruby | String empty? Method empty? is a String class method in Ruby which is used to check whether the string length is zero or not. Syntax: str.empty? Parameters: Here, str is the given string which is to be checked. Returns: It returns true if str has a length of zero, otherwise false. Example 1: Ruby # Ruby program to demon 1 min read Like