Open In App

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

Next Article

Similar Reads