Q:

Write a Ruby program to remove a character from a given string if it starts with that specified character

0

Write a Ruby program to remove a character from a given string if it starts with that specified character

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

my_string = "JJavaScript"
print my_string.sub!(/^J/, '')
my_string = "PPHP"
print "\n",my_string.sub!(/^P/, '')

Output:

JavaScript
PHP

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now