From: Kenny McCormack on
In article <2d6ln5hms244ao2ri0085v0bjinbji90c6(a)4ax.com>,
Hongyi Zhao <hongyi.zhao(a)gmail.com> wrote:
>Hi all,
>
>What's the differences between [[:space:]] and [ \t ] when using both
>in regex pattern?

The former is more current, hip, and "internationale".

If you are using ordinary stuff, there's no difference.

From: Jonathan de Boyne Pollard on
>
>
> If you are using ordinary stuff, there's no difference.
>
You need to read the aforegiven hint, too. (-:

From: Jonathan de Boyne Pollard on
>
>
> Any hints?
>
Here's one: There are more than just the two characters that count as
whitespace.

From: Hongyi Zhao on
On Tue, 16 Feb 2010 05:25:55 -0800 (PST), Janis
<janis_papanagnou(a)hotmail.com> wrote:

>$ grep '[ \t]' <<< $'\v' | od -c
>0000000
>
>$ grep '[[:space:]]' <<< $'\v' | od -c
>0000000 \v \n
>0000002

Excellent examples but obscure for newbie like me to figure out its
meaning, especially the latter part of your codes: <<< $'\v' | od -c.
Any hints?
--
..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
From: Janis Papanagnou on
Chris F.A. Johnson wrote:
> On 2010-02-16, Janis wrote:
>> On 16 Feb., 15:15, Hongyi Zhao <hongyi.z...(a)gmail.com> wrote:
>>> On Tue, 16 Feb 2010 05:25:55 -0800 (PST), Janis
>>>
>>> <janis_papanag...(a)hotmail.com> wrote:
>>>> $ grep '[ \t]' <<< $'\v' | od -c
>>>> 0000000
>>>> $ grep '[[:space:]]' <<< $'\v' | od -c
>>>> 0000000 ?\v ?\n
>>>> 0000002
>>> Excellent examples but obscure for newbie like me to figure out its
>>> meaning, especially the latter part of your codes: <<< $'\v' | od -c.
>> The part
>>
>> CMD <<< STRING
>>
>> is similar to the ancient but often used
>>
>> echo STRING | CMD
>
> It's a non-portable equivalent of the standards-compliant here document:

....of the (for the given purpose) unnecessary bulky standards-compliant
here document. Yes.

>
> CMD <<EOF
> STRING
> EOF
>
>> The $'\CHAR' is used to express control characters \CHAR, like \n for
>> newline or \t for tab.
>
> But it's not standard.

To make it clear, if not apparent; the above posted code is a terse
frame (that is supported in the modern shells, BTW) to *demonstrate*
the _character classes compared to a list of characters_. No less,
and no more.

If you think that another piece of code is more appropriate to show
the OP the difference between [ \t] and [[:space:]] feel free to
post it.

Janis

>
>