Is there a difference between a space and a blank?
Are tabs, spaces, blanks considered characters?
Is there a difference between a space and a blank?
Are tabs, spaces, blanks considered characters?
Since your tag indicates "Regular expression", I assume you are referring to the POSIX character classes [:blank:]
and [:space:]
.
This overview table shows that [:blank:]
is a subset of [:space:]
:
[:space:]
contains everything usually designated as "whitespace characters", i.e. "space" (the character \x20
, generated when pressing the "space" bar), horizontal tab, vertical tab, formfeed etc.[:blank:]
contains only those characters which produce "empty space" within the same line, i.e. "space" and horizontal tab \t
.(*)And yes, in the context of computer input, all these are characters and should therefore also be thought of as characters when designing a regular expression.
Update Here is a similar discussion.
(*) Note: as pointed out by Stéphane Chazelas, there are BSD-based implementations where [:blank:]
can also contain vertical tabulation and formfeed, see e.g. here.
There is no such thing as "blank", in this context. All you have are characters, and some characters that don't actually print anything visible to you in normal text. However, everything is expressed in terms of characters, yes. There are quite a few non-printing characters in ASCII, you can find a full list here: https://web.itu.edu.tr/sgunduz/courses/mikroisl/ascii.html. The ones you are likely to encounter in text files are the various whitespace characters which are:
\t
\n
\r
And, less commonly:
\a
\b
\v
\f
You also have the NULL (\0
) which is non-printing but doesn't appear in text files, as well as the special escape (\e
or ^[
) and Control-Z (^Z
) characters but, again, not really found in text files.
Relevant links
So, a "blank" can be a space or a tab or another whitespace character. Or, if you are working with Unicode and not ASCII, you have various other weird things as well. But no matter what you have, they will be characters. When you see whitespace in text, the computer sees some character. A "blank" is never the absence of a character, it is always the presence of a non-printing character.
man ascii
user manual page. (-:
– JdeBP
Dec 20 '19 at 14:30
ascii
command installed might need to specify the section to the manpage that contains the ASCII table: man 7 ascii
.
– JoL
Dec 21 '19 at 00:20
https://en.wikipedia.org/wiki/Whitespace_character
In computer programming, whitespace is any character or series of characters that represent horizontal or vertical space in typography
I guess you are referring to command line usage:
In commands processed by command processors, e.g., in scripts and typed in, the space character can cause problems as it has two possible functions: as part of a command or parameter, or as a parameter or name separator. Ambiguity can be prevented either by prohibiting embedded spaces, or by enclosing a name with embedded spaces between quote characters.
Space as parameter delimiter:
command arg1 arg2
Space as part of a string (single parameter to command):
command "arg with spaces"
printf '\x20'
and that's the same thing no matter whether it is part of a string or not.
– terdon
Dec 20 '19 at 13:23
YES, If you emphasize on blank, then it is NULL otherwise blank and space are the same. Moreover blank, space and tab all are the char defined by ASCII or Unicode system. blank[0x00], space[0x20], tab[0x09]