[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Extended pattern matching operators and the =~ operator
From: |
M. Nejat AYDIN |
Subject: |
Extended pattern matching operators and the =~ operator |
Date: |
Thu, 2 Jul 2020 05:01:49 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
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?
- Extended pattern matching operators and the =~ operator,
M. Nejat AYDIN <=