get '/foo', :agent => /Songbird (\d.\d)[\d\/]*?/ do "You're using Songbird version #{params[:agent][0]}" end
get '/foo' do # Matches non-songbird browsers end
request.user_agent 匹配 /Songbird (\d.\d)[\d\/]*?/的 => "You're using Songbird version #{params[:agent][0]}", 否则走下面的
request.user_agent
/Songbird (\d.\d)[\d\/]*?/
=> "You're using Songbird version #{params[:agent][0]}"
#1 楼 @dddd1919 request 和 user 怎么解释
#1 楼 @dddd1919 还有,那个空格怎么解释
1.去看 sinatra README 2.SongBird 1.0
sinatra README
SongBird 1.0
1.去看sinatra README
Songbird 1.0
#5 楼 @dddd1919 Songbird 我以为是个普通的字符串
#6 楼 @shangrenzhidao 它在这里面的作用确实就是个具有写实意义的普通字符串
#7 楼 @dddd1919 多谢你,以后遇到问题多问问,我是在官方网站上敲例子,结果卡在那里很久