5

如何删除字符串的第一个“#”字符?

例子:

"fooo#oooooo#bar"

预期结果:

"fooooooooo#bar"

"fooo#oooooo#bar".delete_first("#") // Exist some method like this?
4

1 回答 1

22

sub (not gsub) 这样做:

"fooo#oooooo#bar".sub('#', '') #=> "fooooooooo#bar"
于 2013-05-17T19:05:34.260 回答