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
context.

HOWEVER, this solution while sweet for cygwin-bash, has the CONVERSE
PROBLEM.
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: http://old.nabble.com/Cygwin-bash-regexp-matching-doesn%27t-treat-%22%5Cb%22-properly-tp26500158p26503748.html
Sent from the Cygwin list mailing list archive at Nabble.com.


--
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


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