Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14307 > unrolled thread

Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~

Started byGreg Wooledge <wooledg@eeg.ccf.org>
First post2018-07-10 08:27 -0400
Last post2018-07-10 08:27 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~ Greg Wooledge <wooledg@eeg.ccf.org> - 2018-07-10 08:27 -0400

#14307 — Re: Word boundary anchors \< and \> not parsed correctly on the right side of =~

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-07-10 08:27 -0400
SubjectRe: Word boundary anchors \< and \> not parsed correctly on the right side of =~
Message-ID<mailman.3365.1531225675.1292.bug-bash@gnu.org>
On Mon, Jul 09, 2018 at 10:46:13PM -0300, marcelpaulo@gmail.com wrote:
> Word boundary anchors \< and \> are not parsed correctly on the right side of a =~ regex match expression. 

Bash uses ERE (Extended Regular Expressions) here.  There is no \< or \>
in an ERE.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04

> This evaluates as false:
> 
>     [[ 'foo bar' =~ \<foo\> ]]

Well, of course it does, because \< is just a literal less-than sign
in a POSIX ERE.

wooledg:~$ re='\<foo\>'
wooledg:~$ [[ '<foo>' =~ $re ]] && echo yes
yes

You might as well remove the backslashes, because they serve no purpose
here.  If you thought they meant "word boundary" or something, you're
in the wrong language.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web