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: Cygwin bash regexp matching doesn't treat "\b" properly

Dave Korn writes:

> Bash man page for '~=' refers to man regex(3) which refers to man regex(7)
> which describes word boundary markers as below:
> $ [[ "foo" =~ [[:\<:]]foo[[:\>:]] ]]; echo $?
> 0
> $ [[ "foobar" =~ [[:\<:]]foo[[:\>:]] ]]; echo $?
> 1

Thanks David!
I had actually greppe'd both regex(3) and regex(7) before but I was looking
for the word "word" or "boundary" - neither of which are used in this

HOWEVER, this solution while sweet for cygwin-bash, has the CONVERSE
Apparently, the special strings [[:<:]] and [[:>:]] are not recognized under
Linux regex(7) - they give return code 2.

So, now I have the frustrating situation where \\b works in Linux but not in
Cygwin while [[:<:]] works in Cygwin but not in Linux.

BTW, both regex(7) pages even imply they are POSIX.
Linux: "regex POSIX.2 regular expressions"
Cygwin: "regex - POSIX 1003.2 regular expressions"

Such incompatibility is a PITA because then in a mixed Windows/Linux
environment one has to remember to clutter scripts with ugly "if [ "$OSTYPE"
= "cygwin" ] exceptions, etc.

View this message in context:
Sent from the Cygwin list mailing list archive at

Problem reports:
Unsubscribe info:

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