4
我有以下字符串,我想檢測那裏的換行符。但Ruby的字符串方法include?
未能檢測到它。我正在運行Ruby 1.9.2p290
。我在哪裏錯了?紅寶石未能檢測到字符串中的換行符
"/'ædres/ \nYour ".include?('\n')
=> false
我有以下字符串,我想檢測那裏的換行符。但Ruby的字符串方法include?
未能檢測到它。我正在運行Ruby 1.9.2p290
。我在哪裏錯了?紅寶石未能檢測到字符串中的換行符
"/'ædres/ \nYour ".include?('\n')
=> false
\n
需要用雙引號字符串,否則不會有轉義。
>> "\n".include? '\n'
=> false
>> "\n".include? "\n"
=> true
的
可能重複[我怎樣才能把字符串 「\ n」 從Ruby的字符串?](http://stackoverflow.com/questions/4190797/how-can-i-remove-the-string -n-從-A-紅寶石串) –