203

HTTP code 203: Non-Authoritative Information

Split the Difference

(split.rb) download
1
2
3
4
5
6
7
8
9
s = " To\tbe  or\nnot\tto  be  "
s.split(/ /)
#=> ["", "To\tbe", "", "or\nnot\tto", "", "be"]
s.split(/( )/)
#=> ["", " ", "To\tbe", " ", "", " ", "or\nnot\tto", " ", "", " ", "be", " ", "", " "]
> s.split /\s+/
#=> ["", "To", "be", "or", "not", "to", "be"]
s.split(' ')
#=> ["To", "be", "or", "not", "to", "be"]

From the ruby docs:

If pattern is a single space, str is split on whitespace, with leading whitespace and runs of contiguous whitespace characters ignored.

Note that split by regex without groups omits trailing matches. Undocumented?

Comments