This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why bash failed to match this pattern?


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]