📜  红宝石 |字符串 delete_prefix 方法

📅  最后修改于: 2022-05-13 01:54:28.230000             🧑  作者: Mango

红宝石 |字符串 delete_prefix 方法

delete_prefix是 Ruby 中的 String 类方法,用于返回给定字符串的副本,其中前导前缀已删除。

示例 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")

输出:

by
ass

示例 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")

输出:

Sample
put