Posix Character Sets difference between [[:blank:]] and [[:space:]]?
7,133
The [[:space:]]
class is a superset of [[:blank:]]
which additionally (apart from the space and tab of [[:blank:]]
) includes
- the newline character (
\n
, line feed on Unix, ASCII code 10), - vertical tab (
\v
, ASCII code 11), - form feed (
\f
, ASCII code 12), and - carriage return (
\r
, ASCII code 13).
... in the POSIX locale, that is. Other locales may have additional space characters.
Related videos on Youtube
Author by
Gilles 'SO- stop being evil'
Updated on September 18, 2022Comments
-
Gilles 'SO- stop being evil' over 1 year
On this website it says:
[[:blank:]] space and tab characters [[:space:]] whitespace characters
What's the difference between space and tab characters and whitespace characters? To me, they almost seem the same.
-
Stéphane Chazelas about 7 yearsIOW,
[[:blank:]]
is horizontal spacing characters only while[[:space:]]
contains all horizontal and vertical spacing characters. See also\h
vs\s
inperl
regular expressions. -
Kusalananda about 7 years@StéphaneChazelas Is
\r
a vertical spacing character? -
Stéphane Chazelas about 7 yearsExcept for the space character, the
[[:space:]]
characters in the POSIX locale are all control characters, so the behaviour will vary with the device they are sent to. CR moves the cursor/carriage back to the start of the screen/page so on its own is not really a vertical spacing character, but it's part of the CRLF sequence that is sent to ttys for a line-break so as such can be seen as vertical spacing. -
Stéphane Chazelas almost 4 years