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 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 copy of the string with all characters in the intersection of its arguments deleted. 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\\r\\n" puts str2.delete "\\" Output: Strn Countn Ruby Methodrn 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 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 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_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 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 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 Like