bug-bash
[Top][All Lists]
Advanced

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

Re: Inconsistent regex matching with =~ between bash 3.1 and 3.2


From: Scott Carpenter
Subject: Re: Inconsistent regex matching with =~ between bash 3.1 and 3.2
Date: Wed, 11 Jul 2007 21:45:42 -0500
User-agent: Thunderbird 2.0.0.0 (X11/20070326)

Paul Jarc spake thusly on 07/11/2007 12:10 PM:
Scott Carpenter <address@hidden> wrote:
V="one/two"
[[ ! $V =~ ^\.*/ ]] && echo not

3.1 will remove the backslash as part of basic string parsing, just as
if this were not part of a [[ command, while 3.2 handles the arguments
for [[ specially, and will keep the backslash as part of the regexp.
This will work in both versions:
pattern='^\.*/'
[[ ! $V =~ $pattern ]] && echo not


paul


Thanks, Paul (and Chet for also responding).

I had seen hints about using a variable but when I tried before posting my question I must have used double quotes or no quotes, which didn't work. I tried with single quotes now and works fine, along with parentheses to get BASH_REMATCH: '(^\.*/)'

I really appreciate your guys's patience in answering this newbs question, especially for something that must be an Extreme FAQ by now with the version change. Keep up the great work -- as an escapee from the Windows prison camp, I'm enjoying using and learning more about bash.

Scott




reply via email to

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