bug-sh-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

regex matching bug in expr


From: Jan Nieuwenhuizen
Subject: regex matching bug in expr
Date: 03 Jan 2001 09:33:00 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

Hi,

What's the exact definition for expr's regular expressions?  There
seems to be a bug, see below.  Its behaviour is not what I expect, and
different from grep and sed.

Greetings,
Jan.

from expr info pages:

`STRING : REGEX'
     Perform pattern matching.  The arguments are coerced to strings
     and the second is considered to be a (basic, a la GNU `grep')
     regular expression, with a `^' implicitly prepended.  The first
     argument is then matched against this regular expression.


12:54:28 appel ~$ expr 'whats/wrong/here' : '\([a-z/]*/\).*'

12:54:32 appel ~$ expr 'whats/wrong/here' : '\([a-z]*/\).*'
whats/
12:54:38 appel ~$ echo 'whats/wrong/here' | sed -e s'%^\([a-z/]*/\).*%\1%'
whats/wrong/
12:54:48 appel ~$ echo 'whats/wrong/here' | grep '^\([a-z/]*/\).*'
whats/wrong/here

12:56:18 appel ~$ expr --version
expr (GNU sh-utils) 2.0i
Written by Mike Parker.

Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12:56:22 appel ~$ sed --version
GNU sed version 3.02

Copyright (C) 1998 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
12:56:24 appel ~$ grep --version
grep (GNU grep) 2.4.2

Copyright 1988, 1992-1999, 2000 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]