bug-bash
[Top][All Lists]
Advanced

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

Re: Conditional Regexp matching problem in 3.2


From: Kevin F. Quinn
Subject: Re: Conditional Regexp matching problem in 3.2
Date: Fri, 19 Jan 2007 20:14:52 +0100

On Fri, 19 Jan 2007 00:56:03 -0600 (CST)
address@hidden wrote:

>       # run this, eh?
>       DOG="Dog name - 01 - Wiggles"
>       if [[ $DOG =~ "([[:alpha:][:blank:]]*)- ([[:digit:]]*) -
> (.*)$" ]] then
>          echo Dog ${BASH_REMATCH[2]} is ${BASH_REMATCH[3]}
>       fi

You can actually get it to work in bash 3.2, by writing:

if [[ $DOG =~ ([[:alpha:][:blank:]]*)-\ ([[:digit:]]*)\ -\ (.*)$ ]]
then
  echo Unquoted Dog ${BASH_REMATCH[2]} is ${BASH_REMATCH[3]}
fi

however this fails in 3.1 - it'll work in 3.1 if you also escape the
brackets, but that then fails in 3.2.  Which means the only way to
guarantee it is to write both, and check the bash version :/


Chet,
any comment on this issue? (see also my earlier mail from Sunday 14th,
http://lists.gnu.org/archive/html/bug-bash/2007-01/msg00035.html, and
Tim's bug at
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=220087)
At least to confirm/deny that it may be a real problem?


Thanks,
-- 
Kevin F. Quinn

Attachment: signature.asc
Description: PGP signature


reply via email to

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