Why bash failed to match this pattern?

Mark J. Reed markjreed@gmail.com
Fri Jun 5 05:51:00 GMT 2009


On Fri, Jun 5, 2009 at 1:10 AM, Pan ruochen wrote:
> Hi All,
>
> My current version of bash on cygwin failed to match this pattern:
> *******************************
> target=ar
> if [[ "$target" =~ '^a' ]]; then
>    echo Matched
> else
>    echo Unmatched
> fi

Not a Cygwin question.; that fails in any bash.  The quotes suppress
the special meaning of ^ and make it try to match literally.  Lose
them:

if [[ "$target" =~ ^a ]]; then
...


-- 
Mark J. Reed <markjreed@gmail.com>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list