Hi,
Here is one confusion with String#squeeze.
string = “adb\n\n \n\nbbb”
p string.squeeze(’\n’) #=> “adb\n\n \n\nbbb”
why the \n\n
not being replaced into single \n
?
Hi,
Here is one confusion with String#squeeze.
string = “adb\n\n \n\nbbb”
p string.squeeze(’\n’) #=> “adb\n\n \n\nbbb”
why the \n\n
not being replaced into single \n
?
you need to understand the difference between ‘\n’ and “\n”
Hans M. wrote in post #1107021:
you need to understand the difference between ‘\n’ and “\n”
Yes, for while I forgot the difference between ‘’ and “”. Thanks for
pointing me there.
string = “adb\n\n \n\nbbb”
p string.squeeze("\n") #=> “adb\n \nbbb”
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs