Author -  Sai gowtham

How to use string.delete method in Ruby

In this tutorial, we are going to learn about how to use string.delete in Ruby with the help of examples.

The string.delete method in ruby helps us to delete the specified characters from a string and returns the new string without deleted characters.

Using string.delete method

string.delete "character_list"

The string.delete method accepts one argument which is character_list where we need to specify what characters we need to remove from a given string.

Here is an example:

str = "hamburger"

# it deletes the characters ham from the given string
result = str.delete "ham"
puts result

Output:

"burger"

In the example above, we have specified “ham” as a argument list to the string.delete method. So, it deletes the characters “h, a, m” from the string and returns a new string without those deleted characters.

More examples:

str1 = "audi"
# it deletes the characters d,i from the given string
result1 = str1.delete "di"

str2 = "benz"
# it deletes the characters e,n from the given string
result2 = str2.delete "en"

str3 = "honda"
# it deletes the characters a from the given string
result3 = str3.delete "a"

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY