可能重複: Understanding Symbols In Ruby What is the colon operator in Ruby? 這是一些代碼Rails的教程中,我讀給我。 class Post < ActiveRecord::Base
attr_accessible :content, :name, :title
validates :name, :prese
我想刪除冒號只有當它的字符串的第一個字符。我試過以下,但它不起作用。任何幫助,將不勝感激: //remove the colon if its the first character..
$pattern = '/^:/';
$replace = '';
$tweet = preg_replace($pattern, $replace, $tweet);