delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/19/18:10:18

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Allen Halsey <allenhalsey AT gmail DOT com>
Subject: 1.5, 1.7: Bash regex not recognizing word boundaries
Date: Mon, 19 Oct 2009 20:50:32 +0000 (UTC)
Lines: 21
Message-ID: <loom.20091019T224729-941@post.gmane.org>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

These should print "Matched", but they don't:

$ REGEX='\bcat\b'
$ [[ "dog cat bird" =~ $REGEX ]] && echo "Matched"
$ REGEX='\<cat\>'
$ [[ "dog cat bird" =~ $REGEX ]] && echo "Matched"
$

egrep works as expected:

$ egrep -q '\bcat\b' <(echo "dog cat bird") && echo "Matched"
Matched
$ egrep -q '\<cat\>' <(echo "dog cat bird") && echo "Matched"
Matched
$

Behavior is same on 1.5 and 1.7.

Allen




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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019