标签: ruby-on-rails ruby
如何删除第一个"#"字符串的字符?
"fooo#oooooo#bar"
"fooooooooo#bar" "fooo#oooooo#bar".delete_first("#") // Exist some method like this?
答案 0 :(得分:21)
sub(不是gsub)会这样做:
gsub
"fooo#oooooo#bar".sub('#', '') #=> "fooooooooo#bar"