However, you might be asking yourself how does this one differ from String#trim? It turns out that String#strip is a modern Unicode-aware alternative that relies on the same definition of whitespace as String#isBlank.
To save you the time of digging through docs, the trim method trims whitspace as defined by the unicode space character (\\u0020) whereas the strip will use the isBlank implentation which covers a whole lot more whitspace, defined as:
It is a Unicode space character (SPACE_SEPARATOR,LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0','\u2007', '\u202F'). It is '\t', U+0009 HORIZONTAL TABULATION. It is '\n', U+000A LINE FEED. It is '\u000B', U+000B VERTICAL TABULATION. It is '\f', U+000C FORM FEED.It is '\r', U+000D CARRIAGE RETURN.It is '\u001C', U+001C FILE SEPARATOR.It is '\u001D', U+001D GROUP SEPARATOR.It is '\u001E', U+001E RECORD SEPARATOR.It is '\u001F', U+001F UNIT SEPARATOR.
1
u/sheepdog69 Sep 19 '18
How is
stripdifferent thantrim? They look the same to me. Am I missing something?