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 program to demonstrate # the delete_prefix method # Taking a string and # using the method puts "Ruby".delete_prefix("Ru") puts "Class".delete_prefix("Cl") |
chevron_right
filter_none
Output:
by ass
Example 2:
# 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") |
chevron_right
filter_none
Output:
Sample put
Recommended Posts:
- Ruby | String <=> Method
- Ruby | String + Method
- Ruby | String chr Method
- Ruby | String === Method
- Ruby | String =~ Method
- Ruby | String * Method
- Ruby | String hex Method
- Ruby | String << Method
- Ruby | String eql? Method
- Ruby | String == method
- Ruby | String chars() Method
- Ruby | String encoding Method
- Ruby | String each_line Method
- Ruby | String center() method
- Ruby | String chomp! Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



