Ser*_*nin -4 ruby regex
假设我有一个字符串:
s = "one two three" 如何更换第一个空间 ?
s = "one two three"
返回的字符串应该是"one two three".
"one two three"
bea*_*nie 11
String上的sub方法仅替换第一个匹配项.http://ruby-doc.org/core-1.9.3/String.html#method-i-sub
所以这将完成这项工作
s.sub(" ", " ")
归档时间:
13 年,8 月 前
查看次数:
1647 次
最近记录: