【问题标题】:ruby titleize gives space in between alphabet and numbersruby titleize 在字母和数字之间提供空间
【发布时间】:2013-03-14 09:34:45
【问题描述】:
1.9.3p385 :010 > "Dell Inspiron 14R Laptop".titleize
 => "Dell Inspiron 14 R Laptop" 

你看到了吗?,在 14 和 R 之间添加了一个空格,这会干扰我的搜索。你能想到什么解决办法?

【问题讨论】:

    标签: ruby-on-rails methods title


    【解决方案1】:
    1.9.3p385 :015 > "dell inspiron 14r laptop".titleize
     => "Dell Inspiron 14r Laptop"
    
    1.9.3p385 :016 > "dell inspiron 14R laptop".titleize
     => "Dell Inspiron 14 R Laptop" 
    
    1.9.3p385 :017 > "dell inspiron 14R laptop".downcase.titleize
     => "Dell Inspiron 14r Laptop"
    

    字母部分被小写的字母数字不被视为标题。所以,做一个小写并命名它可以节省你的时间。

    【讨论】:

    • 但是你在14r中得到了小的r
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    相关资源
    最近更新 更多