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

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

Re: regex matching bug in expr


From: Jim Meyering
Subject: Re: regex matching bug in expr
Date: 03 Jan 2001 12:23:51 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.95

Thanks for the report.
Did you build that yourself?  On what sort of system?
Maybe the problem is that it was built to use a buggy version
of a regexp function.  There are some configure-time tests that try
to decide whether to use the included lib/regex.c or the version
in your C library.

It works fine for me using Debian's expr-2.0i and the expr-2.0.11
that I built myself on a pretty old redhat system.

  $ expr 'whats/wrong/here' : '\([a-z/]*/\).*'
  whats/wrong/

Would you please try the latest version?

Jan Nieuwenhuizen <address@hidden> wrote:
| 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.



reply via email to

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