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

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

Re: is expr's \? regex metachar working?


From: Andreas Schwab
Subject: Re: is expr's \? regex metachar working?
Date: 23 Aug 2001 17:05:46 +0200
User-agent: Gnus/5.090003 (Oort Gnus v0.03) Emacs/21.0.105

Clark Morgan <address@hidden> writes:

|> On Thu, Aug 23, 2001 at 04:47:31PM +0200, Andreas Schwab wrote:
|> > ????  The regexp _is_ matching, since expr prints > 0.
|> 
|> $ ./expr "abcdef" : '.*b'
|> 2
|> $ ./expr "abcdef" : '.*b\+'
|> 2
|> $ ./expr "abcdef" : '.*b\?'
|> 6
|> 
|>    Does this illustrate why I think it's broken?

No, not at all.

|>    Remember, the docu says:  0 or 1 matches.  It seems to me that \?
|>    matches 0 occurrences always.

Be carefull with such a statement, you have to check *all* cases, but a
single couterexample is enough to prove the opposite:

$ expr "abcdef" : 'a\?bcd'
4

You can only look at a regexp as a whole, context matters. 

Andreas.

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
address@hidden
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5



reply via email to

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