help-bash
[Top][All Lists]
Advanced

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

Re: Extended pattern matching operators and the =~ operator


From: Eli Schwartz
Subject: Re: Extended pattern matching operators and the =~ operator
Date: Wed, 1 Jul 2020 22:07:39 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 7/1/20 10:01 PM, M. Nejat AYDIN wrote:
> An example given in the Bash Reference Manual, section 3.2.4.2
> Conditional Constructs, seems to imply that extended pattern matching
> operators can be used in the string to the right of the '=~' operator,
> which is suspicious to me. Quoting from the manual:
> 
>   For example, the following will match a line (stored in the shell
>   variable line) if there is a sequence of characters in the value
>   consisting of any number, including zero, of space characters, zero or
>   one instances of ‘a’, then a ‘b’:
>     [[ $line =~ [[:space:]]*?(a)b ]]
>   That means values like ‘aab’ and ‘ aaaaaab’ will match, as will a line
>   containing a ‘b’ anywhere in its value.
> 
> Please notice the use of "?(a)" extended pattern matching expression.
> Is it an error in the manual, or did I overlook something?

This error was fixed in the devel branch as pat of the bash-20191122
snapshot.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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