Ruby | String delete_prefix Method Last Updated : 13 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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 demonstrate # the delete_prefix method # Taking a string and # using the method puts "Ruby".delete_prefix("Ru") puts "Class".delete_prefix("Cl") Output: by ass Example 2: Ruby # Ruby program to demonstrate # the delete_prefix method # Taking a string and # using the method puts "Sample".delete_prefix("am") puts "Input".delete_prefix("In") Output: Sample put Comment More infoAdvertise with us Next Article Ruby | String delete_prefix Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads 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() 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 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_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 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 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 <=> 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 insert Method insert is a String class method in Ruby which is used to inserts the specified string before the character at the given index, modifying the given one. Negative indices count from the end of the string, and insert after the given character. Syntax: str.insert(index, other_str) Parameters: Here, str 1 min read Like