help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] ${var//!([[:class:]])} removing characters of the [:clas


From: Pierre Gaston
Subject: Re: [Help-bash] ${var//!([[:class:]])} removing characters of the [:class:]
Date: Sun, 27 Jan 2013 11:08:41 +0200

On Sun, Jan 27, 2013 at 10:46 AM, Mart Frauenlob
<address@hidden> wrote:
> On 27.01.2013 09:31, Pierre Gaston wrote:
>>
>> On Sun, Jan 27, 2013 at 10:07 AM, Mart Frauenlob
>> <address@hidden> > x=abc
>>>
>>> $ echo "${x/!([[:alpha:]])}"
>>>
>>> $ echo "${x/[![:alpha:]]}"
>>> abc
>>>
>>> still why does the first example remove all alphabetic chars, there can't
>>> be
>>> a match???
>>
>>
>> because inside [[:alpha:]] only matches 1 character
>> so abc is not match by alpha since it is 3 character, abc is the
>> longest string that doesn't match and it removed
>> you get abc with:
>>   x=abc;echo ${x/!(+([[:alpha:]]))}
>>
>
> thank you very much for that explanation!
>
> have a nice day

cool, just for completion (well ok there may be even more)about the
not so obvious things with !()...you should take care that the empty
string is also a "non-match":

$ x=abc;echo ${x//!(+([[:alpha:]]))/r}
rarbrc

each empty string before and after the chars is not matched by "one or
more alpha" and is replaced



reply via email to

[Prev in Thread] Current Thread [Next in Thread]